#include <bits/stdc++.h>   using namespace std;   int mb[3], cd[3];   int mn[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};   bool chk() {     if (mb[1] > 12) return 0;     int i, j, k, tm;     tm = mn[mb[1]];     if (mb[1] == 2 && !(mb[2] & 3)) tm++;     if (tm < mb[0]) return 0;     for (i = mb[2]; i < cd[2]; i++)       ;     i -= (mb[2] + 1);     int dy, m;     if (mb[0] == 29 && mb[1] == 2 && (cd[2] & 3)) {       dy = 1;       m = 3;     } else {       dy = mb[0];       m = mb[1];     }     if (cd[1] > m || (cd[1] == m && cd[0] >= dy)) i++;     return i >= 18;   }   int main() {     bool f = 0;     scanf( %d.%d.%d %d.%d.%d , &cd[0], &cd[1], &cd[2], &mb[0], &mb[1], &mb[2]);     sort(mb, mb + 3);     do {       if (chk()) {         f = 1;         break;       }     } while (next_permutation(mb, mb + 3));     if (f)       puts( YES );     else       puts( NO );     return 0;   }   