#include <bits/stdc++.h>
#define MOD 1000000007

using namespace std;

typedef pair<int,int> P;
typedef pair<int,pair<int,int>> PP;
typedef long long LL;

const double EPS = 1e-8;
const int INF = 1e9;

int dy[] = {0,1,0,-1};
int dx[] = {1,0,-1,0};

int main(void) {
	int a,b,c;
	scanf("%d.%d.%d",&a,&b,&c);
	int d,e,f;
	scanf("%d.%d.%d",&d,&e,&f);

	if(a > d){
		cout << "YES" << endl;
	}else if(a == d && b > e){
		cout << "YES" << endl;
	}else if(a==d && b==e && c >= f){
		cout << "YES" << endl;
	}else 
		cout << "NO" << endl;

	return 0;
}