#include #include #include #include #include #include #include #include #include #include #include #include #define FOR(i, a, b) for(int i=(a);i<=(b);i++) #define RFOR(i, a, b) for(int i=(a);i>=(b);i--) #define MOD 1000000007 #define INF 1000000000 using namespace std; int main(void) { char a[6], b[6]; cin >> a >> b; if (a[0] <= b[0]) { if (a[2] <= b[2]) { if (a[4] < b[4]) { cout << "NO" << endl; } else { cout << "YES" << endl; } } else { cout << "YES" << endl; } } else { cout << "YES" << endl; } return 0; }