#include using namespace std; typedef long long ll; int main() { string one, two; cin >> one >> two; int a = one[0] - '0', b = one[2] - '0', c = one[4] - '0'; int aa = two[0] - '0', bb = two[2] - '0', cc = two[4] - '0'; if (aa < a || (aa <= a && bb < b) || (aa <= a && bb <= b && cc < c)) puts("YES"); else puts("NO"); return 0; }