#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <queue>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = (a); i < (n); i++)
#define MP make_pair
#define all(s) (s).begin(), (s).end()
#define rev(s) (s).rbegin(), (s).rend()
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> P;

int main(){

	map<char, string> m;

	m['A'] = "XY";
	m['B'] = "YX";
	m['X'] = ".Z";
	m['Y'] = "X.";
	m['Z'] = "WB";
	m['W'] = "BY";
	m['.'] = "..";

	string s;
	while(cin >> s, s!="#"){
		char pos = 'A';
		rep(i, s.size()){
			pos = m[pos][s[i]-'0'];
		}
		cout << (pos=='B'?"Yes":"No") << endl;
	}

	return 0;
}