#include using namespace std; signed main(){ string ans[] = { "NO", "YES" }; string v1, v2; cin >> v1 >> v2; if( v1[ 0 ] != v2[ 0 ] ) cout << ans[ v2[ 0 ] <= v1[ 0 ] ] << endl; else if( v1[ 2 ] != v2[ 2 ] ) cout << ans[ v2[ 2 ] <= v1[ 2 ] ] << endl; else if( v1[ 4 ] != v2[ 4 ] ) cout << ans[ v2[ 4 ] <= v1[ 4 ] ] << endl; else cout << "YES" << endl; return 0; }