#include using namespace std; #define dbg(x) (cout<<#x<<" = "<<(x)<<'\n') typedef long long int lld; const int INF = (1LL << 30) - 1; const lld LINF = (1LL << 62) - 1; const int NMAX = 8 * 1000; int N; char sir[NMAX + 5]; deque> B; int main() { cin.sync_with_stdio(false); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif scanf("%s", sir); N = strlen(sir); for (int i = 0; i < N; i += 8) { int trailingzeros = 0; bool locomotiva; for (int j = 7; j >= 0; j--) if (sir[i + j] == '0') trailingzeros++; else break; if (sir[i] == '0') locomotiva = false, trailingzeros = 0; else locomotiva = true; B.push_back({locomotiva, trailingzeros}); } bool ok = true; int nrlastloco = -1; while (!B.empty()) { auto x = B.front(); B.pop_front(); if (nrlastloco > 0) { if (!x.first) nrlastloco--; else ok = false; } else if (nrlastloco == 0) { if (!x.first) ok = false; else nrlastloco = x.second; } else { if (x.first) nrlastloco = x.second; } } printf("%s\n", ok ? "Yes" : "No"); return 0; }