#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair P; int dx[] = { 1, 0, -1, 0 }; int dy[] = { 0, 1, 0, -1 }; const ll MOD = 1000000007; const ll INF = 100000; string s; int cnt; bool judge(){ int cnt2 = 0; for (int i = 0; i < s.size(); i++){ int d = s[i] - '0'; if (i == 0){ if (d != 1 && d != 6 && d != 7) return false; } if (i == s.size() - 1){ if (d < 2 || 4 < d) return false; } if (d == 9) return false; if (d == 8) cnt++; if (d == 1) cnt2++; } if (cnt > 1 || cnt2 > 1) return false; return true; } bool judge2(int L){ for (int i = L; i < s.size(); i++){ int d = s[i] - '0'; if (i == s.size() - 1){ if (d < 2 || 4 < d) return false; } else{ if (d < 3 || 5 < d) return false; } } return true; } int main(void){ cin >> s; if (!judge()){ cout << "No" << endl; return 0; } bool ans; if (s[0] == '1'){ if (s.size() == 1) ans = false; else ans = judge2(1); } else{ for (int i = 0; i < s.size(); i++){ int d = s[i] - '0'; if (d < 6){ if (s[i - 1] == '6' || (s[i - 1] == '7' && cnt == 1)) ans = false; else ans = judge2(i); break; } } } if (ans) cout << "Yes" << endl; else cout << "No" << endl; }