#define _DEB312UG
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const long double pi = acos(-1.0);
const int INF = 1987654321;
const int MOD = 1e9;
// 

int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int cnt[12];

int main(){
#ifdef _DEBUG
    freopen ("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif  
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    int M, D, K; cin >> M >> D >> K;
    for(int i = 0; i < 7; i++){
        string aa = to_string(M);
        for(auto a : aa) cnt[a-'0']++;
        string bb = to_string(D);
        if(bb.length() == 1) cnt[0]++;
        for(auto b : bb) cnt[b-'0']++;
        
        // cout << aa << " " << bb << endl;
        
        D++;
        if(D > days[M-1]){
            if(M == 12){
                M = 1; 
                D = 1;
            }
            else{
                M = M+1;
                D = 1;
            }
        }
    }
    
    int ccntt = 0;
    for(int i = 0; i < 10; i++){
        if(cnt[i] >= 1) ccntt++;
    }
    // cout << ccntt << endl;
    if(ccntt >= K) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}