#include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int> v = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    int M, D, K;
    cin >> M >> D >> K;
    set<char> st;
    for (int i = 0; i < 7; i++) {
        string S = to_string(M);
        string T = to_string(D);
        if ((int)(S.size()) == 1) {
            S = '0' + S;
        }
        if ((int)(T.size()) == 1) {
            T = '0' + T;
        }
        st.insert(S[0]);
        st.insert(S[1]);
        st.insert(T[0]);
        st.insert(T[1]);
        if (D == v[M]) {
            D = 1;
            M++;
            if (M == 13) {
                M = 1;
            }
        } else {
            D++;
        }
    }
    if ((int)(st.size()) >= K) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}