use std::collections::HashSet; fn main() { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let mut n: Vec = s.split_whitespace().flat_map(str::parse).collect(); let d = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; let mut h = HashSet::new(); for _ in 0..7 { format!("{:02}{:02}", n[0], n[1]).chars().for_each(|c| { h.insert(c); }); n[1] += 1; if n[1] > d[n[0]] { n[1] = 1; n[0] = if n[0] == 12 { 1 } else { n[0] + 1 }; } } println!("{}", if h.len() < n[2] { "No" } else { "Yes" }) }