#include <bits/stdc++.h>

void solve(std::istream& is, std::ostream& os) {
  std::array const days = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  int M, D, K;
  is >> M >> D >> K;
  std::stringstream ss;
  for (int _ = 7; _--;) {
    ss << std::setw(2) << std::setfill('0') << M;
    ss << std::setw(2) << std::setfill('0') << D;
    if (D == days[M]) {
      D = 1;
      if (M == 12) {
        M = 1;
      } else {
        ++M;
      }
    } else {
      ++D;
    }
  }
  std::string s = ss.str();
  os << (K <= int(std::set(s.begin(), s.end()).size()) ? "Yes\n" : "No\n");
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  solve(std::cin, std::cout);
}