#include int main(){ int a[2], b[2], c[2]; char ch; for (int i = 0; i < 2; ++i)std::cin >> a[i] >> ch >> b[i] >> ch >> c[i]; bool f; if (a[0] == a[1]){ if (b[0] == b[1])f = (c[0] >= c[1]); else f = (b[0] >= b[1]); } else f = (a[0] >= a[1]); if (f)std::cout << "YES" << std::endl; else std::cout << "NO" << std::endl; return 0; }