using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace yukicoder
{
    class yc
    {
        static void Main()
        {
            string[] str1 = Console.ReadLine().Split('.');
            string[] str2 = Console.ReadLine().Split('.');
            int[] kaseki = new int[3];
            int[] judge = new int[3];

            for (int i = 0; i < 3; i++)
            {
                kaseki[i] = int.Parse(str1[i]);
                judge[i] = int.Parse(str2[i]);
            }

            if (kaseki[0] < judge[0])
            {
                Console.WriteLine("NO");
            }
            else if (kaseki[0] == judge[0])
            {
                if (kaseki[1] < judge[1])
                {
                    Console.WriteLine("NO");
                }
                else if (kaseki[1] == judge[1])
                {
                    if (kaseki[2] < judge[2])
                    {
                        Console.WriteLine("NO");
                    }
                    else Console.WriteLine("YES");
                }
                else Console.WriteLine("YES");
            }
            else Console.WriteLine("YES");
        }
    }
}