// Problem : A. Checking the Calendar
// Contest : Codeforces - Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined)
// URL : https://codeforces.com/problemset/problem/724/A
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define int         long long int
#define vi           vector<int>
#define pii          pair<int,int>
#define vpp          vector<pii>
#define mii          map<int,int>
#define pb           push_back
#define endl        '\n'
#define rep(i,a,bb)  for(int i=a;i<bb;i++)
#define ff           first
#define ss           second
#define fast         ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test         int T;cin>>T;while(T--)
#define __sort(v)    sort(v.begin(),v.end())
#define __rsort(v)   sort(v.rbegin(),v.rend())
#define setbits(x)   __builtin_popcount(x)
#define zrobits(x)   __builtin_ctzint(x)
const int inf = 5 * (1e+8);
const int mod = 1e+9 + 7;
#define ll long long
vector<int> adj[500005];
vector<int> visited(500005, 0);
vector<int> t(500005, 0);
int flag = 1;
void nothing()
{

}

		void solve()
		{
			string s1,s2;
			cin>>s1>>s2;
			map<string, int> week;
			week["monday"]=0;
			week["tuesday"]=1;
			week["wednesday"]=2;
			week["thursday"]=3;
			week["friday"]=4;
			week["saturday"]=5;
			week["sunday"]=6;
			int n=abs(week[s2]-week[s1]);
			// cout<<n<<endl;
			// cout<<week[s2]<<" "<<week[s1]<<endl;
			if((n==3||n==0||n==2) && week[s2]>=week[s1])
			cout<<"YES"<<endl;
			else if((n==5||n==4) && week[s2]<week[s1])
			cout<<"YES"<<endl;
			else
			cout<<"NO"<<endl;
		}
		int32_t main()
		{
			fast;
			solve();
			return 0;
		}

#include <bits/stdc++.h>

using namespace std;
const int oo=1e9;
const long long ooo=1e15;
int t[1001];
vector <vector <int > >g ;
int main()
{
    int n,m;
    string s,s1;
    cin >>s>>s1;
    map <string ,int > mon;
    mon ["monday"]=0;
    mon ["tuesday"]=1;
    mon ["wednesday"]=2;
    mon [ "thursday"]=3;
    mon ["friday"]=4;
    mon ["saturday"]=5;
    mon ["sunday"]=6;
    if ((mon[s]+31)%7==mon[s1] ||mon[s1]==(30+mon[s])%7||mon[s1]==(28+mon[s])%7 )
            cout <<"YES";
    else
        cout << "NO";

    return 0;
}

#include <stdio.h>
#include <iostream>
#include <string>
#include <string.h>
using namespace std;

int main(){
	int a,b;
	string s;
	cin>>s;
	if (s=="monday") a=1;
	else if (s=="tuesday") a=2;
	else if (s=="wednesday") a=3;
	else if (s=="thursday") a=4;
	else if (s=="friday") a=5;
	else if (s=="saturday") a=6;
	else if (s=="sunday") a=7;

	cin>>s;
	if (s=="monday") b=1;
	else if (s=="tuesday") b=2;
	else if (s=="wednesday") b=3;
	else if (s=="thursday") b=4;
	else if (s=="friday") b=5;
	else if (s=="saturday") b=6;
	else if (s=="sunday") b=7;

	int x=(b-a+7)%7;
	char *answer = "NO";
	if (x==0||x==3||x==2)
		answer = "YES";

	cout << answer << endl;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    string s1,s2;
    string a[7];
    a[0] = "monday";
    a[1] ="tuesday";
    a[2] = "wednesday";
    a[3] = "thursday";
    a[4] = "friday";
    a[5] = "saturday";
    a[6] = "sunday";

    cin >> s1 >> s2;

    for (int i = 0; i < 7; i ++)
    {
        if (s1 == a[i])
        {
            if (s2 == a[i])
            {
                cout << "YES";
            }
            else if (s2 == a[(i + 2) % 7])
            {
                cout << "YES";
            }
            else if (s2 == a[(i + 3) % 7])
            {
                cout << "YES";
            }
            else
            {
                cout << "NO";
            }
        }
    }
    return 0;
}

#include <bits/stdc++.h>
#define ps push_back
#define fi first
#define se second
using namespace std;
const int maxn = 1000 + 10;
const int inf = 0x3f3f3f3f;
typedef long long ll;
typedef unsigned long long ULL;
const double eps = 1e-10;

int m[100000][13];
map<string,int>mp;
bool run(int y){
//    return 1;
    if (y % 4 == 0 && y % 400 != 0)return 1;
    if (y % 400 == 0)return 1;
    return 0;
}
int la(int mo){
    return mo == 1 || mo == 3 || mo == 5 || mo == 7 || mo == 8 ||mo == 10 ||mo == 12;
}
int main(){
    mp["monday"] = 0;
    mp["tuesday"] = 1;
    mp["wednesday"] = 2;
    mp["thursday"] = 3;
    mp["friday"] = 4;
    mp[ "saturday"] = 5;
    mp["sunday"] = 6;
    string a,b;
    cin >> a >>b;
    int u = mp[a],v = mp[b];
    m[2015][2] = 6;
//    m[2015][3] = 7;
    for (int i = 2015; i <= 20000; ++i){
        for (int j = (i == 2015 ? 3 : 1); j <= 12; ++j){
            int pre;
            int p;
            if (j == 1)pre = m[i-1][12],p = 12;
            else pre = m[i][j-1],p = j-1;
//            if (i == 2015 && j == 5)printf("123      %d\n",p);
            if (p != 2){
                if (la(p)) {
                    m[i][j] = (pre + 31) % 7;
//                    if (i == 2015 && j == 5)printf("123      %d\n",p);
                }
                else {
                    m[i][j] = (pre + 30) % 7;
//                    if (i == 2015 && j == 12)printf("123      %d\n",pre);
                }
            }else {
                if (run(i)){
                    m[i][j] = (pre + 29) % 7;

                }else m[i][j] = (pre + 28) % 7;
            }
        }
    }
//    printf("%d\n",m[2017][7]);
//    printf("%d -- %d  %d\n",m[2017][8],u,v);
    bool ok = 0;
    for (int i = 2015; i <= 20000; ++i){
        for (int j = (i == 2015 ? 2 : 1); j < 12; ++j){
                if (run(i))continue;
                int cur = m[i][j];
                int nes;
                if (j == 12)nes = m[i+1][1];
                else nes = m[i][j+1];
            if (cur == u && nes == v){
//                printf("%d %d %d",i,j,j+1);
                ok = 1;
                goto TT;
            }
        }
    }
    TT:
        if (ok)puts("YES");
        else puts("NO");

    return 0;
}

#include<bits/stdc++.h>

using namespace std;

string x, y;
string s[7] {  "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday" };
int a [ 12 ] { 31, 28 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 } ;
int ans , cnt ;
void solve ( )
{

    cin >> x >> y;
    for( int i = 0 ; i < 7; i ++ )
    {
        if( s [ i ] == x  )
            cnt = i ;
        if( s [ i ] == y )
            ans = i ;
    }
    for( int i = 0; i < 11 ; i ++ )
    {
        if( ( cnt + a [ i ] ) % 7 == ans )
        {
            cout << "YES"  << endl ;
            return ;
        }
    }
    cout << "NO" << endl ;
}
main ( )
{
    ios_base::sync_with_stdio(0)  ;
    long long int T  = 1 ;
   /// freopen("input.txt","r",stdin);
   /// freopen("output.txt","w",stdout);
///    cin >> T ;
    while ( T -- )
    {
        solve ( ) ;
    }
}
/// 1  2  3 4 5 6 7 8 9 10 11 12 13 14
///              1 2

#include <iostream>
#include <map>

using namespace std;

string answer(string d1, string d2){
    map<string, int> weekdays; weekdays.insert(pair<string,int>("monday",1));
    weekdays.insert(pair<string,int>("tuesday",2));
     weekdays.insert(pair<string, int>("wednesday",3));
    weekdays.insert(pair<string,int>("thursday",4)); weekdays.insert(pair<string,int>("friday",5));
     weekdays.insert(pair<string,int>("saturday",6)); weekdays.insert(pair<string,int>("sunday",7));
    int duration[3] ={3,0,2};

    for(int i =0; i<3;i++){
        if((duration[i]+weekdays.find(d1)->second)%7==(weekdays.find(d2)->second)%7)return "YES";
    }
    return "NO";
}
int main(){

    string day1="", day2="";

    cin>>day1;cin>>day2;

    cout<<answer(day1,day2);
return 0;
}

#include <stdio.h>
#include <string.h>
#include <math.h>

int months [12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
char str1[10];
char str2[10];
int day_1, day_2, cur_day, i, q, prev_day, d;

int main()
{
	scanf("%s", str1);
	if (!strcmp(str1, "monday"))
		day_1 = 1;
	if (!strcmp(str1, "tuesday"))
		day_1 = 2;
	if (!strcmp(str1, "wednesday"))
		day_1 = 3;
	if (!strcmp(str1, "thursday"))
		day_1 = 4;
	if (!strcmp(str1, "friday"))
		day_1 = 5;
	if (!strcmp(str1, "saturday"))
		day_1 = 6;
	if (!strcmp(str1, "sunday"))
		day_1 = 7;
	scanf("%s", str2);
	if (!strcmp(str2, "monday"))
		day_2 = 1;
	if (!strcmp(str2, "tuesday"))
		day_2 = 2;
	if (!strcmp(str2, "wednesday"))
		day_2 = 3;
	if (!strcmp(str2, "thursday"))
		day_2 = 4;
	if (!strcmp(str2, "friday"))
		day_2 = 5;
	if (!strcmp(str2, "saturday"))
		day_2 = 6;
	if (!strcmp(str2, "sunday"))
		day_2 = 7;
	for (d = 1; d < 8; d++)
	{
		cur_day = prev_day = d;
		for (q = 0; q < 12; q++)
		{
			for (i = 1; i <= months[q]; i++)
			{
				if (cur_day != 7) cur_day++;
				else cur_day = 1;
			}
			if (prev_day == day_1 && cur_day == day_2) { printf("YES"); return 0; }
			prev_day = cur_day;
		}
	}

	printf("NO");

	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <iostream>
#include <functional>
#include <time.h>
#include <cmath>
#include <assert.h>
#include <deque>
#include <iomanip>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define piii pair<int, pair<int, int> >
#define plll pair<ll, pair<ll, ll> >

ll EPS = 1000000007;
const int INF = 1000000000;
double PI = 3.14159265358979323846;
const int MAXN = 1000040;

ll abss(ll h) {
    return max(h, -h);
}

double fabss(double h) {
    return max(h, -h);
}

ll ceill(ll x, ll y) {
    if (x % y != 0) return (x / y) + 1;
    return x / y;
}

string itos(ll num) {
    string str = "";
    if (num == 0) return "0";
    while (num != 0) {
        str += ((num % 10) + '0');
        num /= 10;
    }
    reverse(str.begin(), str.end());
    return str;
}

ll sstoi(string num) {
    ll count = 1;
    for (int i = 0; i < (int)num.size() - 1; i++) {
        count *= 10;
    }
    ll ans = 0;
    for (int i = 0; i < (int)num.size(); i++) {
        ans += (num[i] - '0') * count;
        count /= 10;

    }
    return ans;
}

ll n, m, k, h;

int a[MAXN] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int b[MAXN];
int c[MAXN];

string str[30] = {"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
	string str1, str2;
	cin >> str1 >> str2;
	for (int i = 0; i < 7; i++)
	{
		vector <string> firstdays;
		int ind = i;
		firstdays.push_back(str[ind]);
		for (int j = 0; j < 12; j++)
		{
			int t = a[j];
			while (t != 0)
			{
				t--;
				ind++;
				if (ind == 7)
				{
					ind = 0;
				}
			}
			firstdays.push_back(str[ind]);
		}
		for (int j = 0; j < firstdays.size() - 1; j++)
		{
			if (firstdays[j] == str1 && firstdays[j + 1] == str2)
			{
				cout << "YES";
				return 0;
			}
		}
	}
	cout << "NO";
}

#include <bits/stdc++.h>
int main()
{
    std::map<std::string, int> weekdays;
    weekdays["monday"] = 1;
    weekdays["tuesday"] = 2;
    weekdays["thursday"] = 4;
    weekdays["sunday"] = 7;
    weekdays["saturday"] = 6;
    weekdays["friday"] = 5;
    weekdays["wednesday"] = 3;

    std::string day1, day2;

    std::getline(std::cin, day1);
    std::getline(std::cin, day2);
    int n, k;
    // let's see if the gap is 31 days

    if(day1 == day2) {
        std::cout << "YES" << std::endl;
        return 0;
    }

    n = (weekdays[day1]+30)%7;
    if(n == 0) n = 7;

    if(n == weekdays[day2]) {
        std::cout << "YES" << std::endl;
        return 0;
    }

    n = (weekdays[day1]+31)%7;
    if(n == 0) n = 7;

    if(n == weekdays[day2]) {
        std::cout << "YES" << std::endl;
        return 0;
    }

    std::cout << "NO" << std::endl;

    return 0;
}

#include<bits/stdc++.h>
#define r_0 return 0
#define pb push_back
#define ll long long
#define fr first
#define se second

using namespace std;

const int N = 1e3;
map<char ,int >mp,m1;
map<string , int>m2;
int used[N][N];
int use[100000];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
      cout.tie(0);

          /// freopen( "input.txt", "r", stdin );
            /// freopen( "output.txt", "w", stdout );

      string s1,s2, s[7] = { "sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"};
     int x,a[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
     cin >> s1 >> s2;
      if ( s1 == s2 )
        cout << "YES\n";
      else{
            int z= 6,y,x;
          while( z >=0 )
          {
              if( s[z] == s1 )
                x = z+1;
              else if( s[z] == s2 )
                y = z+1;
                z --;
          }
          if ( y < x )
            x = 7 - x + y;
            else
                x = y -x;
          if( x == 2 or x == 3 )
            cout << "YES\n";
          else
            cout<< "NO\n";

      }
}

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{	char a[20],b[20];
	char s[20][20]={"monday","tuesday","wednesday", "thursday", "friday", "saturday", "sunday","monday","tuesday","wednesday", "thursday", "friday", "saturday", "sunday"};
	int k,i,j;
	gets(a);
	gets(b);
	for(i=0;i<15;i++)
		if(strcmp(a,s[i])==0)
			break;
	for(j=i+1;;j++)
		if(strcmp(s[j],b)==0)
			break;
	k=j-i;
	if(k==0||k==2||k==3||k==7)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;

}

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <iterator>
#include <cstdio>
#include <vector>
#include <string>
#include <regex>
#include <numeric>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <utility>
#include <random>
#include <bitset>
#include <list>
#include <functional>
#include <chrono>
#include <fstream>
#include <array>
using namespace std;
template<class T, typename A = allocator<T>>
class Vector : public vector<T, A>
{
public:
	using vector<T, A>::vector;
	using typename vector<T, A>::size_type;
	using typename vector<T, A>::value_type;
	using typename vector<T, A>::allocator_type;
	Vector& operator()(size_type dummy_n, const value_type& val = value_type(), const allocator_type& alloc = allocator_type()) { return *this; }
};
template<> class Vector<string> : public vector<string> { public:using vector<string>::vector; Vector& operator()(size_type dummy_n) { return *this; } };
typedef long long ll;            typedef unsigned int u;
typedef pair<int, int> pii;      typedef pair<u, u> puu;
typedef Vector<bool> vb;// Vector
typedef Vector<int> vi;          typedef Vector<u> vu;
typedef Vector<ll> vll;
typedef Vector<string> vs;
typedef Vector<pii> vpii;        typedef Vector<puu> vpuu;
typedef Vector<Vector<int>> vvi; typedef Vector<Vector<u>> vvu;
typedef set<int> si;             typedef set<u> su;
typedef multiset<int> Si;        typedef multiset<u> Su;
typedef map<int, int> mi;        typedef map<u, u> mu;
typedef multimap<int, int> Mi;   typedef multimap<u, u> Mu;
template <typename Int = int> // only integral types
inline Int read() // "([number][space or newline])*" // reads -int_max but doesn't read int_min
{
	int c{ getchar() };
	if (c == '-') {
		Int init{ getchar() & 15 };
		while ((c = getchar()) & 16) init = (init << 3) + (init << 1) + (c & 15);
		return ++(init = ~init);
	}
	else {
		Int init{ c & 15 };
		while ((c = getchar()) & 16) init = (init << 3) + (init << 1) + (c & 15);
		return init;
	}
}
inline void read(int& a) // "([number][space or newline])*" // reads -int_max but doesn't read int_min
{
	a = getchar() & 15;
	if (a == 13) {
		a = getchar() & 15;
		for (int c; (c = getchar()) & 16; a = (a << 3) + (a << 1) + (c & 15));
		++(a = ~a);
	}
	else
		for (int c; (c = getchar()) & 16; a = (a << 3) + (a << 1) + (c & 15));
}
inline void read(unsigned int& a) // "([number][space or newline])*"
{
	a = getchar() & 15;
	for (int c; (c = getchar()) & 16; a = (a << 3) + (a << 1) + (c & 15));
}
inline void read(char& a) { do scanf("%c", &a); while (isspace(a)); }
inline void read(string& a) { static char BUF[1234560]; scanf("%s", BUF); a = move(string(BUF)); }
inline void read(ll& a) { a = read<ll>(); }
inline void read(double& a) { scanf("%lf", &a); }
inline void read(pii& a) { read(a.first); read(a.second); }
template<template<typename T, typename A = allocator<T> > class C, class T>
inline void read(C<T>& a) { for (auto i = a.begin(); i != a.end(); ++i) read(*i); }
template < typename T, typename U, typename... ARGS >
inline void read(T& t, U& u, ARGS&... args) {
	read(t),// comma
		read(u, args...);
}
template <typename Int> // only integral types
inline void write(Int x)
{
	static char BUF[64] = {};
	char *pnt{ BUF + 64 };
	if (x < 0) {
		putchar('-');
		++(x = ~x);
	}
	do
		*--pnt = x % 10 | 48;
	while (x /= 10);
	printf("%s", pnt);
}
inline void write(unsigned int a)
{
	static char BUF[16] = {};
	char *pnt{ BUF + 16 };
	do
		*--pnt = a % 10 | 48;
	while (a /= 10);
	printf("%s", pnt);
}
inline void write(const char& a) { printf("%c", a); }
inline void write(const char* a) { printf("%s", a); }
inline void write(const string& a) { printf("%s", a.c_str()); }
inline void write(const double& a) { printf("%lf", a); }
inline void write(const pii& a) { write(a.first); write(' '); write(a.second); }
template<template<typename T, typename A = allocator<T> > class C, class T>
inline void write(const C<T>& a) { if (a.size()) write(*a.begin()); for (auto i = ++a.begin(); i != a.end(); ++i) { write(' '); write(*i); } }
template < typename T, typename U, typename... ARGS >
inline void write(const T& t, const U& u, const ARGS&... args) {
	write(t),// comma
		write(' '),
		write(u, args...);
}
template<template<typename T, typename A = allocator<T> > class C, class T>
inline void sort(C<T>& a) { sort(a.begin(), a.end()); }
inline void sort(string& a) { sort(a.begin(), a.end()); }
template<template<typename T, typename A = allocator<T> > class C, class T>
inline void rsort(C<T>& a) { sort(a.rbegin(), a.rend()); }
inline void rsort(string& a) { sort(a.rbegin(), a.rend()); }
template<typename T>
inline int sz(const T& a) { return int(a.size()); }
template < template < class T, class Compare = less<T>, class Alloc = allocator<T> > class C, class T>
inline bool in(const C<T>& c, const T& el) { return c.find(el) != c.end(); };
template < template < class Key, class T, class Compare = less<Key>, class Alloc = allocator<pair<const Key, T> > > class C, class Key, class T>
inline bool in(const C<Key, T>& c, const Key& el) { return c.find(el) != c.end(); };
template < template < class T, class Compare = less<T>, class Alloc = allocator<T> > class C, class T>
inline bool out(const C<T>& c, const T& el) { return c.find(el) == c.end(); };
template < template < class Key, class T, class Compare = less<Key>, class Alloc = allocator<pair<const Key, T> > > class C, class Key, class T>
inline bool out(const C<Key, T>& c, const Key& el) { return c.find(el) == c.end(); };
#define MX 1000000000
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define T(n) for(decltype(n) _VARIABLE{(n) + 1}; --_VARIABLE;)
#define F(b,e,i) for(auto i = (b); i != (e); (b) < decltype(b)(e) ? ++i : --i)
#define G(f,l,i) for(auto i = (f) + ((f) < decltype(f)(l) ? -1 : 1); ((f) < decltype(f)(l) ? i++ : i--) != (l) ;)
#define M(f,l,i,j) for(auto i = (f) , j = decltype(f)(l) ; i < j; ++i, --j)
#define R(type, ...) type __VA_ARGS__; read(__VA_ARGS__)
#define W(...) write(__VA_ARGS__), write('\n')
#define bgn begin()
#define rbgn rbegin()
#define nd end()
#define rnd rend()
#define pb push_back
#define fnt front()
#define bck back()
#define x first
#define y second

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
	array<u, 12> d_in_m{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	array<string, 7> d_of_w{ "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday" };
	R(string, fs, se);
	for (auto d_in_m_el : d_in_m) {
		auto ind_fs = find(all(d_of_w), fs) - d_of_w.bgn;
		auto ind_se = find(all(d_of_w), se) - d_of_w.bgn;
		if ((ind_fs + d_in_m_el % 7) % 7 == ind_se) {
			W("YES");
			return 0;
		}
	}
	W("NO");
}
//
// ArtemParkhomets
//

#include <bits/stdc++.h>

#define sz(s) s.size()
#define sr(s) sort(s.begin(), s.end())
#define rs(s) reverse(s.begin(), s.end())
#define ar(a, n) sort(a + 1, a + n + 1)
#define ra(a, n) reverse(a + 1, a + n + 1)
#define solved exit(0);
#define S second
#define F first

typedef long long ll;

using namespace std;

const int N = 1e5 + 15;
const int LL = 1e9 + 15;
const int SSS = 1e6 + 15;

string s, t, dd[10] = {"", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};

int i1, i2, ans, days[15] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

main()
{

	cin >> s >> t;
	for (int i = 1; i <= 7; ++i)
	{
		if (s == dd[i])
			i1 = i;
		if (t == dd[i])
			i2 = i;
	}
	for (int i = 1; i <= 12; ++i)
	{
		ans = i1;
		ans += (days[i] % 7);
		if (ans > 7)
			ans %= 7;
		if (ans == i2)
		{
			cout << "YES";
			return 0;
		}
	}
	cout << "NO";
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll i,j,m,n,p,q,r;
string s[20]={"sunday", "wednesday","wednesday", "saturday", "monday", "thursday", "saturday","tuesday","friday","sunday", "wednesday","friday"};
string a[10]={"sunday","monday", "tuesday", "wednesday", "thursday", "friday", "saturday"};
string x,y;
map<string,ll>mp;
int main()
{
    for(i=0;i<7;i++)
        mp[a[i]]=i;
    cin>>x>>y;
    for(i=0;i<11;i++)
    {
        if(i==3)
            {
        for(j=0;j<12;j++)
        s[j]=a[(mp[s[j]]+1)%7];
            }
        else
        {
            for(j=0;j<11;j++)
            {
                if(x==s[j]&&y==s[j+1])
                {
                    cout<<"YES";
                    return 0;
                }
            }
    for(j=0;j<12;j++)
    s[j]=a[(mp[s[j]]+1)%7];
        }

    }
    cout<<"NO";
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll i,j,m,n,p,q,r;
string s[20]={"sunday", "wednesday","wednesday", "saturday", "monday", "thursday", "saturday","tuesday","friday","sunday", "wednesday","friday"};
string a[10]={"sunday","monday", "tuesday", "wednesday", "thursday", "friday", "saturday"};
string x,y;
map<string,ll>mp;
int main()
{
    for(i=0;i<7;i++)
        mp[a[i]]=i;
    cin>>x>>y;
    for(i=0;i<100;i++)
    {
        if(i==3)
            {
        for(j=0;j<12;j++)
        s[j]=a[(mp[s[j]]+1)%7];
            }
        else
        {
            for(j=0;j<11;j++)
            {
                if(x==s[j]&&y==s[j+1])
                {
                    cout<<"YES";
                    return 0;
                }
            }
    for(j=0;j<12;j++)
    s[j]=a[(mp[s[j]]+1)%7];
        }

    }
    cout<<"NO";
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll i,j,m,n,p,q,r;
string s[20]={"sunday", "wednesday","wednesday", "saturday", "monday", "thursday", "saturday","tuesday","friday","sunday", "wednesday","friday"};
string a[10]={"sunday","monday", "tuesday", "wednesday", "thursday", "friday", "saturday"};
string x,y;
map<string,ll>mp;
int main()
{
    for(i=0;i<7;i++)
        mp[a[i]]=i;
    cin>>x>>y;
    for(i=0;i<13;i++)
    {
        if(i==3)
            {
        for(j=0;j<12;j++)
        s[j]=a[(mp[s[j]]+1)%7];
            }
        else
        {
            for(j=0;j<11;j++)
            {
                if(x==s[j]&&y==s[j+1])
                {
                    cout<<"YES";
                    return 0;
                }
            }
    for(j=0;j<12;j++)
    s[j]=a[(mp[s[j]]+1)%7];
        }

    }
    cout<<"NO";
}

#include<iostream>
#include<string.h>

using namespace std;

int main()
{
	int monthdays[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	char *dayofweek[] = { "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday" };
	char d1[10], d2[10];
	cin >> d1 >> d2;

	int a, b, day, i;
	for (i = 0; i < 7;i++)
		if (strcmp(d1, dayofweek[i]) == 0)
			a = i;
	for (i = 0; i < 7; i++)
		if (strcmp(d2, dayofweek[i]) == 0)
			b = i;
		day = b - a;
		if (day < 0)
			day += 7;
		int flag = 0;
		for (i = 0; i < 12;i++)
		if (day == monthdays[i] % 7)
		{
			flag = 1;
			break;
		}
		if (flag)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	return 0;
}

#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<string, string> pss;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<string, int> psi;

//#define USE_TEXTFILE
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define BG begin()
#define EN end()
#define SS stable_sort
#define BS binary_search

int main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);

#ifdef USE_TEXTFILE
#define cout file
	ofstream file;
	file.open("abc.txt");
#endif

	string days[] = { "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};

	string d1, d2; cin >> d1 >> d2;

	if (d1 == d2) {

		cout << "YES\n";

		return 0;

	}

	int id1, id2;

	for (int i = 0; i < 7; i++) {

		if (days[i] == d1)
			id1 = i;

		if (days[i] == d2)
			id2 = i;

	}

	if ((id1 + 3) % 7 == id2) {

		cout << "YES\n";

		return 0;

	}

	if ((id1 + 2) % 7 == id2) {

		cout << "YES\n";

		return 0;

	}

	cout << "NO\n";

}

#include<iostream>
#include<string>
#include<cstring>
#include<set>
#include<map>
#include<vector>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
int main()
{
	string a,b;
	cin>>a>>b;
	int t=0;
	if(a=="monday")
	{
		if(b=="monday"|| b=="wednesday" ||b=="thursday")
		{
			cout<<"YES";
			t=1;
		}
	}
	if(a=="tuesday")
	{
		if(b== "friday"|| b=="tuesday" ||b=="thursday")
		{
			cout<<"YES";
			t=1;
		}
	}
	if(a=="wednesday")
	{
		if(b== "friday"|| b=="saturday"|| b=="wednesday")
		{
			cout<<"YES";
			t=1;
		}
	}
	if(a== "thursday")
	{
		if( b=="saturday"|| b=="sunday" ||b=="thursday")
		{
			cout<<"YES";
			t=1;
		}
	}
	if(a== "friday")
	{
		if(b== "friday"|| b=="sunday" ||b=="monday")
		{
			cout<<"YES";
			t=1;
		}
	}

	if(a== "saturday")
	{
		if(b== "tuesday"|| b=="saturday" ||b=="monday")
		{
			cout<<"YES";
			t=1;
		}
	}
	if(a== "sunday")
	{
		if(b== "tuesday"|| b=="wednesday"|| b=="sunday" )
		{
			cout<<"YES";
			t=1;
		}
	}
	if(t==0)
	cout<<"NO";
	return 0;
}

#include <bits/stdc++.h>
#define maxn
#define FILE "test"

using namespace std;
string s[9],s1,s2;
int n1,n2,n,a[14];

void init()
{
    s[2]="monday";
    s[3]="tuesday";
    s[4]="wednesday";
    s[5]="thursday";
    s[6]="friday";
    s[7]="saturday";
    s[8]="sunday";
    a[1]=a[13]=2;a[2]=5;a[3]=5;a[4]=7;a[5]=3;a[6]=5;a[7]=8;a[8]=4;a[9]=6;a[10]=2;a[11]=4;
    a[12]=7;
}

int main()
{
    ios_base::sync_with_stdio(0);
    //freopen(FILE".inp","r",stdin);
    //freopen(FILE".out","w",stdout);
    init();
    cin >> s1;
    cin >> s2;
    for (int i=2;i<=8;i++)
    {
        if (s[i]==s1) n1=i;
        if (s[i]==s2) n2=i;
    }
    n=n1-n2;
    for (int i=1;i<=12;i++)
        if (a[i]-a[i+1]==n)
    {
        cout << "YES";
        return 0;
    }
    cout << "NO";return 0;
}

#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <cfloat>
#include <iterator>
#include <algorithm>
#include <numeric>
#include <cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned uint;
typedef long double l_double;

#define gcd __gcd
#define FFS(var) __builtin_ffs(var)
#define CLZ(var) __builtin_clz(var)
#define CTZ(var) __builtin_ctz(var)
#define POPCOUNT(var) __builtin_popcount(var)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define s_cast static_cast // <>
#define deb(x) cerr << "[" << #x << "] -> [" << x << "] "
#define deb2(x,y) cerr << "[" << #x << ", " << #y << "] -> [" << x << ", " << y << "] "
#define deb3(x,y,z) cerr << "[" << #x << ", " << #y << ", " << #z << "] -> [" << x << ", " << y << ", " << z << "] "
#define debVV(V) cerr << #V << ":\n" << V << endl; // 2D
#define ENDL << endl;  // debug

const double PI {3.1415926535897932384626433832795};
const int MOD {static_cast<int>(1e9 + 7)};
const double EPS {1e-9};

// 1D-----------------------------------------------------
template<typename T, size_t N>  // array extraction
istream& operator>>(istream &is, array<T, N> &ARR) {
    for (T &a: ARR) is >> a;
    return is;
}

template<typename T, size_t N>  // array insertion
ostream& operator<<(ostream &os, array<T, N> &ARR) {
    for (T const &a: ARR) os << a << " ";
    return os;
}

template<typename T>  // vector extraction
istream& operator>>(istream &is, vector<T> &VEC) {
    for (T &v: VEC) is >> v;
    return is;
}

template <typename T>  // vector insertion
ostream& operator<<(ostream &os, const vector<T> &VEC) {
    for (T const &v: VEC) os << v << " ";
    return os;
}

template<typename T>  // deque extraction
istream& operator>>(istream &is, deque<T> &DEQ) {
    for (T &d: DEQ) is >> d;
    return is;
}

template<typename T>  // deque insertion
ostream& operator<<(ostream &os, const deque<T> &DEQ) {
    for (const T &d: DEQ) os << d << " ";
    return os;
}

template<typename T>  // list extraction
istream& operator>>(istream &is, list<T> &LIS) {
    for (T &l: LIS) is >> l;
    return is;
}

template<typename T>  // list insertion
ostream& operator<<(ostream &os, const list<T> &LIS) {
    for (T const &l: LIS) os << l << " ";
    return os;
}

template<typename T>  // set insertion
ostream& operator<<(ostream &os, const set<T> &ST) {
    for (auto const &s: ST) os << s << " ";
    return os;
}

template<typename T>  // unordered_set insertion
ostream& operator<<(ostream &os, const unordered_set<T> &U_ST) {
    for (T const &us: U_ST) os << us << " ";
    return os;
}

template<typename T1, typename T2>  // pair extraction
istream& operator>>(istream &is, pair<T1, T2> &PR) {
    is >> PR.first >> PR.second;
    return is;
}

template<typename T1, typename T2>  // pair debug
ostream& operator<<(ostream &os, const pair<T1, T2> &PR) {
    os << "[" << PR.first << ": " << PR.second << "]";
    return os;
}

template<typename T1, typename T2>  // map debug
ostream& operator<<(ostream &os, const map<T1, T2> &MP) {
    os << "[ ";
    for (pair<T1, T2> const &m: MP) os << m << " ";
    os << "]";
    return os;
}

template<typename T1, typename T2>  // unordered_map debug
ostream& operator<<(ostream& os, const unordered_map<T1, T2> &U_MP) {
    os << "[ ";
    for (pair<T1, T2> const &um: U_MP) os << um << " ";
    os << "]";
    return os;
}

template<typename T>  // stack debug
ostream& operator<<(ostream &os, stack<T> STACK) {
    while (!STACK.empty()) {
        os << STACK.top() << " ";
        STACK.pop();
    }
    return os;
}

template<typename T>  // queue debug
ostream& operator<<(ostream &os, queue<T> QUEUE) {
    while (!QUEUE.empty()) {
        os << QUEUE.front() << " ";
        QUEUE.pop();
    }
    return os;
}

// 2D----------------------------------------------------------------

template<typename T, size_t R, size_t C>  // 2D array insertion
ostream& operator<<(ostream &os, array<array<T, C>, R> &MAT) {
    for (array<T, C> &ROW: MAT) os << ROW << endl;
    return os;
}

template<typename T>  // 2D vector insertion
ostream& operator<<(ostream &os, vector<vector<T>> &MAT) {
    for (vector<T> &ROW: MAT) os << ROW << endl;
    return os;
}

template<typename T>
T max(const T &A, const T &B, const T &C) {
    T mx {A};
    (mx < B) && (mx = B);
    (mx < C) && (mx = C);
    return mx;
}

template<typename T>
T min(const T &A, const T &B, const T &C) {
    T mn {A};
    (mn > B) && (mn = B);
    (mn > C) && (mn = C);
    return mn;
}

template<typename T>
int cntDigits(const T &N) { return (static_cast<int>(log10(N)) + 1); }

template<typename T>
bool isPowOfTwo(const T &N) { return (N && (!(N&(N-1)))); }

template<typename T>
bool dblEqual(const T &a, const T &b) { return abs(a - b) < EPS; }

/* -------------------------------------------------------- */
/* -------------------------------------------------------- */

//

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cerr.setf(std::ios::boolalpha);
    cout << std::fixed;
    cout << std::setprecision(6); // default
    /* ---------------------------------- */

    const array<string, 7> ref1 {"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};
    const array<int, 12> ref2 {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    string d1 {}, d2 {};
    cin >> d1 >> d2;

    bool found {false};
    int ind {s_cast<int>(std::find(all(ref1), d1) - ref1.begin())};
    for (int i {}; i < 12; ++i) {
    	int rem {ref2.at(i)%7};
    	int ind2 {(ind+rem)%7};
    	if (ref1.at(ind2) == d2) {
    		found = true;
    		break;
    	}
    }
    cout << (found ? "YES": "NO") << endl;
    return 0;
}

#include<iostream>
using namespace std;
int main()
{
    string one, two;
    int f, s;
    cin>>one>>two;
    if(one == "saturday")
        f = 1;
    else if(one == "sunday")
        f = 2;
    else if(one == "monday")
        f = 3;
    else if(one == "tuesday")
        f = 4;
    else if(one == "wednesday")
        f = 5;
    else if(one == "thursday")
        f = 6;
    else if(one == "friday")
        f = 7;

    if(two == "saturday")
        s = 1;
    else if(two == "sunday")
        s = 2;
    else if(two == "monday")
        s = 3;
    else if(two == "tuesday")
        s = 4;
    else if(two == "wednesday")
        s = 5;
    else if(two == "thursday")
        s = 6;
    else if(two == "friday")
        s = 7;

    int dif;
    if(f == s)
        cout<<"YES";
    else
    {
        if(f <= 4)
        {
            dif = s - f;
            if(dif == 2 || dif == 3)
                cout<<"YES";
            else
                cout<<"NO";
        }
        else
        {
            if((f == 5 && s == 7) || (f == 5 && s == 1))
                cout<<"YES";
            else if((f == 6 && s == 1) || (f == 6 && s == 2))
                cout<<"YES";
            else if((f == 7 && s == 2) || (f == 7 && s == 3))
                cout<<"YES";
            else
                cout<<"NO";
        }

    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,index1,index2,ans;
    string day[7]={"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};
    string str1,str2;
    cin>>str1>>str2;
            for(i=0;i<7;i++)
        {
            if(str1==day[i])
                index1=i+1;
            if(str2==day[i])
                index2=i+1;
        }
        if(index1>index2)
        {
            index1=7-index1;
        ans=index1+index2;
        }
            else
                ans=index2-index1;
                if(ans==3||ans==2||ans==0)
                    cout<<"YES"<<endl;
                else
                    cout<<"NO"<<endl;
    }

#include<bits/stdc++.h>

using namespace std;

int main()
{
    int arr[20]={31,28,31,30,31,30,31,31,30,31,30,31};
    string day[10]={"monday","tuesday","wednesday","thursday","friday","saturday","sunday"};

    bool flag=false;

    string str,endi;
    cin>>str>>endi;

    int i,j;

    int y1,y2;
    for(i=0;i<7;i++)
    {
        if(day[i]==str)
        {
            y1=i;
            break;
        }
    }

    for(i=0;i<7;i++)
    {
        if(day[i]==endi)
        {
            y2=i;
            break;
        }
    }

 //   cout<<y1<<"  "<<y2<<endl;

    int yy1,yy2;
    yy1=(y1+3)%7;
    yy2=(y1+2)%7;

   if(str==endi)
    {
        cout<<"YES"<<endl;
        return 0;
    }
    if(day[yy1]==endi)
    {
        cout<<"YES"<<endl;
        return 0;
    }
    if(day[yy2]==endi)
    {
        cout<<"YES"<<endl;
        return 0;
    }
    cout<<"NO"<<endl;
    return 0;

}

// MINAMINO#
#include <bits/stdc++.h>
#define maxn 100000
#define F first
#define S second
#define mp make_pair
#define PB push_back
#define mod 1000000007
#define ll long long
#define inf 0x3f3f3f3f
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mp make_pair
#define pb push_back
#define sz(v) (int)v.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
using namespace std;
string s1,s2;
string s[100];
int main()
{
    //freopen("TXT.INP","r",stdin);

    cin >> s1 >> s2;
    s[1]="monday";
    s[2]="tuesday";
    s[3]="wednesday";
    s[4]="thursday";
    s[5]= "friday";
    s[6]="saturday";
    s[7]= "sunday";
    for (int i=8; i<=14; i++) s[i] = s[i-7], s[i+7]= s[i];
    int ok=0;
    for ( int i=8; i<=14; i++)
        if ( s[i] == s1 )
        {
            if ( s2 == s[i]|| s2 == s[i+2] || s2 == s[i+3] ) ok =1;

        }
        if ( ok == 1 )cout <<"YES"; else cout <<"NO";
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i;
    ios::sync_with_stdio(false);
    string str[14]={"monday","tuesday","wednesday","thursday","friday","saturday",
                    "sunday","monday","tuesday","wednesday","thursday","friday",
                    "saturday","sunday"};

    string str1,str2;
    cin>>str1>>str2;
    if(str1==str2){
        cout<<"YES"<<endl;
        return 0;
    }
    for(int i=0;i<14;i++){
        if(str[i]==str1){
            if(str[i+2]==str2||str[i+3]==str2){
                cout<<"YES"<<endl;
                return 0;
            }
        }

    }
    cout<<"NO"<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i;
    ios::sync_with_stdio(false);
    string str[14]={"monday","tuesday","wednesday","thursday","friday","saturday",
                    "sunday","monday","tuesday","wednesday","thursday","friday",
                    "saturday","sunday"};

    string str1,str2;
    cin>>str1>>str2;
    if(str1==str2){
        cout<<"YES"<<endl;
        return 0;
    }
    for(int i=0;i<14;i++){
        if(str[i]==str1){
            if(str[i+2]==str2||str[i+3]==str2){
                cout<<"YES"<<endl;
                return 0;
            }
           // else break;
        }

    }
    cout<<"NO"<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i;
    ios::sync_with_stdio(false);
    string str[14]={"monday","tuesday","wednesday","thursday","friday","saturday",
                    "sunday","monday","tuesday","wednesday","thursday","friday",
                    "saturday","sunday"};

    string str1,str2;
    cin>>str1>>str2;
    if(str1==str2){
        cout<<"YES"<<endl;
        return 0;
    }
    for(int i=0;i<14;i++){
        if(str[i]==str1){
            if(str[i+2]==str2||str[i+3]==str2){
                cout<<"YES"<<endl;
                return 0;
            }
            else break;
        }

    }
    cout<<"NO"<<endl;
    return 0;
}

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <string>
#include <bitset>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

int main()
{
	//freopen("ReadMe.txt", "r", stdin);
	//freopen("", "w", stdout);
	int week[2];
	for (int i = 0; i < 2; i++)
	{
		string s;
		int res = 0;
		cin >> s;
		if (s == "monday")
			res = 1;
		if (s == "tuesday")
			res = 2;
		if (s == "wednesday")
			res = 3;
		if (s == "thursday")
			res = 4;
		if (s == "friday")
			res = 5;
		if (s == "saturday")
			res = 6;
		if (s == "sunday")
			res = 7;
		week[i] = res;
	}
	int diff[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	for (int i = 0; i < 12; i++)
	{
		int n = week[0];
		n += diff[i] % 7;
		if (n > 7)
			n -= 7;
		if (n == week[1])
		{
			cout << "YES";
			return 0;
		}
	}
	cout << "NO";
	return 0;
}
/*

*/

#include<bits/stdc++.h>
using namespace std;
map<string,int> mp;
int main(){
	string s1,s2;
	cin>>s1>>s2;
	int k=7;
	mp["sunday"]=0;
	mp["monday"]=1;
	mp["tuesday"]=2;
	mp["wednesday"]=3;
	mp["thursday"]=4;
	mp["friday"]=5;
	mp["saturday"]=6;
	//cout<<mp[s2]-mp[s1]<<endl;
	//cout<<k-mp[s2]+mp[s1]<<endl;
	if (mp[s2]-mp[s1]<=3 and mp[s2]-mp[s1]!=1  and mp[s2]>=mp[s1])
		cout<<"YES"<<endl;
	else if(k-mp[s1]+mp[s2]<=3 and 1 and k-mp[s1]+mp[s2]!=1)
			cout<<"YES"<<endl;

	else cout<<"NO"<<endl;
	return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <list>
#include <algorithm>
#include <map>
#include <string>
#include <cstdlib>

#define MAXN 15000
#define LL long long
#define uint unsigned int

using namespace std;

char weeks[8][10]={"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};

int months[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int getWeekId(char s[]){
	for(int i=0; i<7; i++){
		if(strcmp(s, weeks[i])==0){
			return i;
		}
	}
	return -1;
}

bool judge(int f, int s){
	int sum ;
	int ff,ss;
	for(int i=0; i<7; i++){
		ff = i;
		for(int j=1;j<12;j++){
			ss = ( ((months[j-1])%7) + ff ) % 7;
			if(f==ff&&s==ss){
				return true;
			}
			ff = ss;
		}
	}
	return false;
}

int main(){
#ifdef CDZSC_OFFLINE
	freopen("in.txt","r",stdin);
#endif //CDZSC_OFFLINE

	char fs[10], ss[10];

	scanf("%s%s",fs,ss);
	int f, s;

	f = getWeekId(fs);
	s = getWeekId(ss);

	if(judge(f,s)){
		printf("YES\n");
	} else {
		printf("NO\n");
	}

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
string str[8]={"","monday","tuesday","wednesday","thursday","friday","saturday","sunday"};
string str1,str2;
inline int check(string st){
	for(int i=1;i<=7;i++){
		if(st==str[i]){
			return i;
		}
	}
}
int main(){
	cin>>str1>>str2;
	int q1=check(str1);
	int q2=check(str2);
	if((q1+7)%7==(q2+7)%7||q1%7==(q2+7)%7||(q1+2)%7==(q2+7)%7||(q1+3)%7==(q2+7)%7){
		cout<<"YES";
	}else{
		cout<<"NO";
	}
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int daysInMonth[11] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30};
map <string, int> p = {{"monday", 1}, {"tuesday", 2}, {"wednesday", 3},
					   {"thursday", 4}, {"friday", 5}, {"saturday", 6},
					   {"sunday", 7}};

int calc(int start, int daysAfter) {
	for (int i = 0; i < daysAfter; i++) {
		start++;
		if (start == 8)
			start = 1;
	}
	return start;
}

int main() {
	string a, b;
	cin >> a >> b;

	int first = p[a], second = p[b];

	for (int i = 0; i < 11; i++)
		if (calc(first, daysInMonth[i]) == second)
			cout << "YES", exit(0);

	cout << "NO";
	return 0;
}

#include <iostream>
#include <set>
#include <cmath>
#include <cstring>
using namespace std;

multiset <int> q;

int main() {
    int n1, n2;
    string s;
    cin>>s;
    if (s == "monday")
        n1 = 1;
    else if (s == "tuesday")
        n1 = 2;
    else if (s == "wednesday")
        n1 = 3;
    else if (s == "thursday")
        n1 = 4;
    else if (s == "friday")
        n1 = 5;
    else if (s == "saturday")
        n1 = 6;
    else
        n1 = 7;
    cin>>s;
    if (s == "monday")
        n2 = 1;
    else if (s == "tuesday")
        n2 = 2;
    else if (s == "wednesday")
        n2 = 3;
    else if (s == "thursday")
        n2 = 4;
    else if (s == "friday")
        n2 = 5;
    else if (s == "saturday")
        n2 = 6;
    else
        n2 = 7;

    if (((n1 + 31) % 7 == n2 % 7) || ((n1 + 30) % 7 == n2 % 7) || ((n1 + 28) % 7 == n2 % 7)) {
        cout<<"YES";
    }
    else cout<<"NO";

    return 0;
}

#include <iostream>
#include <string>
#include <map>
using namespace std;

string s1,s2;
string day[] = {"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday","monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};
//map<
int main() {
	cin >> s1 >> s2;
	for(int i = 0; i < 7; i++) {
		for(int j = i; j < 14; j++) {
			if(day[i] == s1 && day[j] == s2) {
				if(j - i == 0 || j - i == 3 || j - i == 2) {
					puts("YES");
					return 0;
				}
			}
		}
	}
	puts("NO");

}

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
char qdu[7][10] = { "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};
int main()
{
    char a[10];
    char b[10];
    gets(a);
    gets(b);
    int date_a;
    for(int i = 0;i < 7;i++)
    {
        if(!strcmp(qdu[i],a))
        {
            date_a = i+1;
            break;
        }
    }
    int date_b;
    for(int i = 0;i < 7;i++)
    {
        if(!strcmp(qdu[i],b))
        {
            date_b = i+1;
            break;
        }
    }
    int res;
    if(date_b < date_a)
        date_b += 7;
    res = date_b - date_a;
    if(res == 0 || res == 2 || res == 3)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}

#include<bits/stdc++.h>

using namespace std;
int main(){
int a,b,n;
string s1,s2;
cin>>s1;
cin>>s2;
vector<int> v;
map<string,int> v2;
v2.insert({"monday",1});
v2.insert({"tuesday",2});
v2.insert({"wednesday",3});
v2.insert({"thursday",4});
v2.insert({"friday",5});
v2.insert({"saturday",6});
v2.insert({"sunday",7});
//cout<<v2[s1]<<" "<<v2[s2];
a=v2[s1];
b=v2[s2];
//cout<<a<<" "<<b;
if(v2[s1]<=2){
if(abs(a-b)==0||abs(a-b)==2||abs(a-b)==3)
cout<<"YES";
    else
cout<<"NO";
}
else if(v2[s1]==3){
if(abs(a-b)==0||a-b==-2||abs(a-b)==3)
cout<<"YES";
    else
cout<<"NO";
}
else if(v2[s1]==4){
if(abs(a-b)==0||a-b==-2||a-b==-3)
cout<<"YES";
    else
cout<<"NO";
}
else if(v2[s1]==5){
    if(abs(a-b)==0||a-b==-2||a-b==4)
cout<<"YES";
else
cout<<"NO";
}
else if(v2[s1]==6){
    if(abs(a-b)==0||abs(a-b)==5||abs(a-b)==4)
cout<<"YES";
else
cout<<"NO";
}
else if(v2[s1]==7){
    if(abs(a-b)==0||abs(a-b)==4||abs(a-b)==5)
cout<<"YES";
else
cout<<"NO";
}
else
cout<<"NO";
return 0;
}

#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

char mon[7][20] = {"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};

int main(){
    char s1[20], s2[20];

    scanf("%s", s1);
    scanf("%s", s2);

    int n1, n2;

    for(n1 = 0; n1 < 7; ++ n1){
        if(strcmp(mon[n1], s1) == 0){
            break;
        }
    }

    for(n2 = 0; n2 < 7; ++ n2){
        if(strcmp(mon[n2], s2) == 0){
            break;
        }
    }

    int flag = 0;
    if(n1 == n2){
        flag = 1;
    }
    if((n2 + 7 - n1) % 7 == 2){
        flag = 1;
    }
    if((n2 + 7 - n1) % 7 == 3){
        flag = 1;
    }

    if(flag){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define optimize() 		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll				long long
#define vll				vector<long long>
#define pb				push_back
#define w(x)			int x; cin>>x; while(x--)
#define mp      		make_pair
#define F 				first
#define S 				second
#define mod     		1000000007
#define inf     		1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define endl	  		"\n"
#define sp 				" "
#define ca(x) 			"Case "<<x<<": "
#define all(x) 			x.begin(), x.end()
#define loop(i,a,n)		for (int i = a; i < (n); ++i)
#define rloop(i,a,n)	for (int i = n; i >= (a); --i)
#define in(n)			long long n ; cin >> n;
#define ins(s)			string s; cin >> s;
#define yes				cout << "YES"<<"\n"
#define no				cout << "NO"<<"\n"

int main()
{
	optimize();
	//............. S I D A T I V E  H I P N O T I X .............//

	map<string, int>m;

	m["monday"] = 0;
	m["tuesday"] = 1;
	m["wednesday"] = 2;
	m["thursday"] = 3;
	m["friday"] = 4;
	m["saturday"] = 5;
	m["sunday"] = 6;

	string s, ss;
	cin >> s >> ss;
	int n = (m[ss] - m[s]);
	if (n < 0)
	{
		n += 7;
	}
	if (n == 0 or  n == 2 or n == 3)yes;
	else no;

	return 0;
}

#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdint>

int main()
{
    std::map<std::string, uint32_t> days;
    days["monday"] = 0;
    days["tuesday"] = 1;
    days["wednesday"] = 2;
    days["thursday"] = 3;
    days["friday"] = 4;
    days["saturday"] = 5;
    days["sunday"] = 6;

    std::string day0, day1;
    std::cin >> day0 >> day1;

    if (days.find(day0) == days.end() || days.find(day1) == days.end())
    {
        return -1;
    }

    int32_t delta = days[day1] - days[day0];
    if (delta < 0) delta = delta + 7;

    if (delta == 0 || delta == 2 || delta == 3)
    {
        std::cout << "YES\n";
        return 0;
    }
    std::cout << "NO\n";

    return 0;
}

#include <iostream>
#include <fstream>
#include <string>

int main() {

	std::string day1, day2;
	std::cin >> day1 >> day2;

	int nDay1, nDay2;

	if (day1 == "monday") {
		nDay1 = 1;
	}
	else if (day1 == "tuesday") {
		nDay1 = 2;
	} else if (day1 == "wednesday") {
		nDay1 = 3;
	}
	else if (day1 == "thursday") {
		nDay1 = 4;
	}
	else if (day1 == "friday") {
		nDay1 = 5;
	}
	else if (day1 == "saturday") {
		nDay1 = 6;
	}
	else if (day1 == "sunday") {
		nDay1 = 7;
	}

	if (day2 == "monday") {
		nDay2 = 1;
	}
	else if (day2 == "tuesday") {
		nDay2 = 2;
	}
	else if (day2 == "wednesday") {
		nDay2 = 3;
	}
	else if (day2 == "thursday") {
		nDay2 = 4;
	}
	else if (day2 == "friday") {
		nDay2 = 5;
	}
	else if (day2 == "saturday") {
		nDay2 = 6;
	}
	else if (day2 == "sunday") {
		nDay2 = 7;
	}

	if (nDay1 == nDay2 || (nDay2 + 7 - nDay1)%7 == 3 || (nDay2 + 7 - nDay1)%7 == 2) {
		std::cout << "YES";
	}
	else {
		std::cout << "NO";
	}

	return 0;
}

#include<iostream>
using namespace std;
void calendar (string,string);
string s,s1; int a,b;
main(){
 cin>>s>>s1;
 calendar(s,s1);
}

void calendar(string s,string s1){
 if(s1=="monday")   b=1;
 else if(s1=="tuesday") b=2;
 else if(s1=="wednesday") b=3;
 else if(s1=="thursday") b=4;
 else if(s1=="friday") b=5;
 else if(s1=="saturday") b=6;
 else b=7;

 if(s=="monday")   a=1;
 else if(s=="tuesday") a=2;
 else if(s=="wednesday") a=3;
 else if(s=="thursday") a=4;
 else if(s=="friday") a=5;
 else if(s=="saturday") a=6;
 else a=7;

if(b-a==0 ||  b-a==2 || b-a==3 || b-a==-5 ||b-a==-4)
cout<<"YES";
else
cout<<"NO";
}

#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<set>
using namespace std;
#define pi acos(-1.0)
#define EPS 1e-6    //log(x)
#define e exp(1.0); //2.718281828
#define mod 1000000007
#define INF 0x7fffffff
#define inf 0x3f3f3f3f
typedef long long LL;

#define debug(x) cout<<x<<endl;
#define debug2(x) cout<<x<<" ";

int m[22]={0,31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main()
{
    char A[10],B[10];
    int a,b;
    scanf("%s",&A);
    scanf("%s",&B);
    if(strcmp(A,"monday")==0) a=1;
    if(strcmp(A,"tuesday")==0) a=2;
    if(strcmp(A,"wednesday")==0) a=3;
    if(strcmp(A,"thursday")==0) a=4;
    if(strcmp(A,"friday")==0) a=5;
    if(strcmp(A,"saturday")==0) a=6;
    if(strcmp(A,"sunday")==0) a=0;

    if(strcmp(B,"monday")==0) b=1;
    if(strcmp(B,"tuesday")==0) b=2;
    if(strcmp(B,"wednesday")==0) b=3;
    if(strcmp(B,"thursday")==0) b=4;
    if(strcmp(B,"friday")==0) b=5;
    if(strcmp(B,"saturday")==0) b=6;
    if(strcmp(B,"sunday")==0) b=0;
    bool ok=false;
    for(int i=1;i<=12;i++){
        int day=m[i];
        if((a+day%7)%7==b) ok=true;
    }

    if(ok) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

#include <iostream>
#include <string>
using namespace std;

int main() {

    string first;
    string second;
    int d,z,q;

    cin>> first;
    cin>> second;

    if(first=="monday")
        d=1;
    if(first=="tuesday")
        d=2;
    if(first=="wednesday")
        d=3;
    if(first=="thursday")
        d=4;
    if(first=="friday")
        d=5;
    if(first=="saturday")
        d=6;
    if(first=="sunday")
        d=7;

    if(second=="monday")
    {q=1;z=8;}
    if(second=="tuesday")
    { q=2;z=9;}
    if(second=="wednesday")
    {q=3;z=10;}
    if(second=="thursday")
    {q=4;z=11;}
    if(second=="friday")
    {q=5;z=12;}
    if(second=="saturday")
    {q=6;z=13;}
    if(second=="sunday")
    {q=7;z=14;}

    if (q==(d+2) || z==(d+2) || q==(d+3) || z==(d+3) || q==d) {
        cout<<"YES";}
    else
    {cout<<"NO";}

    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define Lson L, mid, ls[rt]
#define Rson mid+1, R, rs[rt]
const int maxn=1e5+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
inline ll read()
{
    ll x=0;int f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m,k,t,c[]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
char a[maxn],b[maxn];
map<string,int>d;
int main()
{
    int i,j;
    d["monday"]=1;
    d["tuesday"]=2;
    d["wednesday"]=3;
    d["thursday"]=4;
    d["friday"]=5;
    d["saturday"]=6;
    d["sunday"]=7;
    scanf("%s%s",a,b);
    int co=(d[b]-d[a]+7)%7;
    rep(i,0,11)
    {
        if(c[i]%7==co)return 0*puts("YES");
    }
    puts("NO");
    //system("Pause");
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <iterator>

#define ll long long
#define ld long double

#define y1 abc

#define endl '\n'

#define fi first
#define se second

#define pb push_back
#define pob pop_back

using namespace std;

ll a1, a2;

string s1, s2;

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> s1;

    cin >> s2;

    if (s1 == "monday") a1 = 1;
    else if (s1 == "tuesday") a1 = 2;
    else if (s1 == "wednesday") a1 = 3;
    else if (s1 == "thursday") a1 = 4;
    else if (s1 == "friday") a1 = 5;
    else if (s1 == "saturday") a1 = 6;
    else a1 = 7;

    if (s2 == "monday") a2 = 1;
    else if (s2 == "tuesday") a2 = 2;
    else if (s2 == "wednesday") a2 = 3;
    else if (s2 == "thursday") a2 = 4;
    else if (s2 == "friday") a2 = 5;
    else if (s2 == "saturday") a2 = 6;
    else a2 = 7;

    if (a2 < a1) a2 += 7;

    if (a2 - a1 == 0 || a2 - a1 == 2 || a2 - a1 == 3) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

#include<string>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
string s1,s2;
string s[]={"sunday","monday","tuesday","wednesday","thursday","friday","saturday"};
int main(){
	int ok=0,w1,w2;
	cin>>s1>>s2;
	for(int i=0;i<=6;i++){
		if(s1==s[i])w1=i;
		if(s2==s[i])w2=i;
	}
	if(w1==w2||(w1+2)%7==w2||(w1+3)%7==w2)ok=1;
	if(ok)puts("YES");
	else puts("NO");
	return 0;
}

//
//  main.cpp
//  a-checking_the_calendar
//
//  Created by david chong on 5/29/19.
//  Copyright © 2019 david chong. All rights reserved.
//

#include <iostream>
#include <string>
#include <vector>
#include <fstream>

using namespace std;

string dow[7] = { "sunday","monday","tuesday","wednesday","thursday","friday","saturday" };

vector<int> punchCard;

int convert(int i) {
//    cout << i << " ";
    if(i > 6) {
        return (i%7);
    }
    if(i == -1) {
        return 6;
    }
    return i;
}

void month(string myDay) {

    int idx = -1;

    for(int j = 0; j < 7; j++) {

        if(dow[j] == myDay) {
            idx = j;
            break;
        }
    }

    int feb = 32;
    int march = feb + 28;
    int april = march + 31;
    int may = april + 30;
    int june = may + 31;
    int july = june + 30;
    int august = july + 31;
    int september = august + 31;
    int october = september + 30;
    int november = october + 31;
    int december = november + 30;

    int monthMarker[12] = {1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30};

    int myIdx = -1;
    int diff;

    int j = 0;

    int sum;

    for(int i = 1; i < 366; i++) {

        if(i == 1) {
            sum = i;
            punchCard.push_back(convert(idx));
            j++;
        }

        if(i % 7 == 0) {
            myIdx = i;
        }

        diff = i - myIdx;

        if(sum + monthMarker[j] == i) {
            sum = i;
            punchCard.push_back(convert(idx+diff-1));
            j++;
        }
    }

}

int main(int argc, const char * argv[]) {

//    fstream cin("input.in");

    string first, second, temp;
    bool flagOne = false;
    bool flagTwo = false;

    cin >> first >> second;

    cin.clear();
    fflush(stdin);

    punchCard.clear();

    month(dow[0]);

    int myMonth = -1;

    for(int i = 0; i < 7; i++) {
        flagOne = false;
        for(int k = 0; k < punchCard.size(); k++) {

            temp = dow[convert(punchCard[k] + i)];

//            cout << temp << endl;

            if(flagOne && temp == second) {
                if(k == (myMonth + 1)) {
                    flagTwo = true;
                    break;
                }
            }

            if(temp == first) {
                flagOne = true;
                myMonth = k;
            }
//            cout << temp << endl;
        }

//        cout << endl;

        if(flagOne && flagTwo) {
            break;
        }
    }

    if(flagOne && flagTwo) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s,c;
    int a,b;
    cin >> s;
    if (s=="monday")
    {
        a=0;
    }
    if (s=="tuesday")
    {
        a=1;
    }
      if (s=="wednesday")
    {
        a=2;
    }
      if (s=="thursday")
    {
        a=3;
    }
      if (s=="friday")
    {
        a=4;
    }
      if (s=="saturday")
    {
        a=5;
    }
      if (s=="sunday")
    {
        a=6;
    }
    cin >> c;
    if (c=="monday")
    {
       b=0;
    }
    if (c=="tuesday")
    {
        b=1;
    }
      if (c=="wednesday")
    {
        b=2;
    }
      if (c=="thursday")
    {
        b=3;
    }
      if (c=="friday")
    {
        b=4;
    }
      if (c=="saturday")
    {
        b=5;
    }
      if (c=="sunday")
    {
        b=6;
    }
    if(a == b || (a+2)%7 == b || (a+3)%7 == b)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }

    return 0;
}

#include<bits/stdc++.h>
using namespace std ;
int main()
{
    int n,p;
    string s,s1 ;
    cin>>s>>s1;
    if(s=="saturday") n=1;
    else if(s=="sunday") n=2;
    else if(s=="monday") n=3;
    else if(s=="tuesday") n=4;
    else if(s=="wednesday") n=5;
    else if(s=="thursday") n=6;
    else if(s=="friday") n=7;
    if(s1=="saturday") p=1;
    else if(s1=="sunday") p=2;
    else if(s1=="monday") p=3;
    else if(s1=="tuesday") p=4;
    else if(s1=="wednesday") p=5;
    else if(s1=="thursday") p=6;
    else if(s1=="friday") p=7;

    int w=n-p;
 if( w==0 || w==4 || w== -3 || w== -2 || w==5 ) printf("YES");
    else printf("NO");
}

#include<iostream>
#include<cstdio>
#include<string.h>
using namespace std;
int main()
{
    int a1,b1, c[15]= {3,0, 3, 2, 3, 2, 3, 3, 2, 3, 2, 3},e,f,x,y,z;
    string a,b;
    cin>>a;
    getchar();
    cin>>b;
    if(a=="saturday")
        a1=1;
    else if(a=="sunday")
        a1=2;
    else if(a=="monday")
        a1=3;
    else if(a=="tuesday")
        a1=4;
    else if(a=="wednesday")
        a1=5;
    else if(a=="thursday")
        a1=6;
    else if(a=="friday")
        a1=7;

    if(b=="saturday")
        b1=1;
    else if(b=="sunday")
        b1=2;
    else if(b=="monday")
        b1=3;
    else if(b=="tuesday")
        b1=4;
    else if(b=="wednesday")
        b1=5;
    else if(b=="thursday")
        b1=6;
    else if(b=="friday")
        b1=7;
    e=0;
    for(x=0; x<12; x++)
    {
        f=(a1+c[x]);
        if(f>7)
            f=f-7;
        if(f==b1)
        {
            e++;
            break;
        }
    }
    if(e==0)
        cout<<"NO"<<endl;
    else
        cout<<"YES"<<endl;
    return 0;
}

#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <map>
using namespace std;
int main()
{
    map <string,int> pp;
    pp["monday"]=1;
    pp["tuesday"]=2;
    pp["wednesday"]=3;
    pp["thursday"]=4;
    pp["friday"]=5;
    pp["saturday"]=6;
    pp["sunday"]=7;
    string s,t;
    cin>>s>>t;
    int a=(pp[t]-pp[s]+7)%7;
    (a==0 || a==2 || a==3) ? cout<<"YES\n" : cout<<"NO\n";
    return 0;
}

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
map<string,int> mp;
char s1[30],s2[30];
int main()
{
    mp["monday"]=0;
    mp["tuesday"]=1;
    mp["wednesday"]=2;
    mp["thursday"]=3;
    mp["friday"]=4;
    mp["saturday"]=5;
    mp["sunday"]=6;
    while(~scanf("%s%s",s1,s2))
    {
        int x=(mp[s2]-mp[s1]+7)%7;
        if(x==0||x==3||x==2)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}

#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
map<string,int> a;
int main(){
	string b,c;
	a["monday"]=0;
	a["tuesday"]=1;
	a["wednesday"]=2;
	a["thursday"]=3;
	a["friday"]=4;
	a["saturday"]=5;
	a["sunday"]=6;
	cin>>b>>c;
	int x=a[c]-a[b];
	if(x>=0){
		if(x==0||(x==2||x==3))
			cout<<"YES";
		else
			cout<<"NO";
	}
	else{
		if(x==-5||x==-4)
			cout<<"YES";
		else
			cout<<"NO";
	}
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
#ifdef gsdt
    freopen("input.txt","r",stdin);
#endif // gsdt

    string day[7]={"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};
    string a,b; cin>>a>>b;
    int x,y;
    for(x=0; x<7; x++) if(a==day[x]) break;
    for(y=0; y<7; y++) if(b==day[y]) break;

    cout<<((x==y || (x+2)%7==y || (x+3)%7==y)?"YES":"NO");

    return 0;
}

#include "cstdio"
#include "cstring"
#include "algorithm"
#include "iostream"
#include "map"
using namespace std;
int main()
{
    map<string,int> map;
    map["monday"]=0;
    map["tuesday"]=1;
    map["wednesday"]=2;
    map["thursday"]=3;
    map["friday"]=4;
    map["saturday"]=5;
    map["sunday"]=6;
	string a,b;
    cin>>a>>b;
	if ((map[a]+30)%7==map[b]||(map[a]+28)%7==map[b]||(map[a]+31)%7==map[b])
	{
        printf("YES\n");
	}
    else
    {
        printf("NO\n");
    }

return 0;
}

#include <iostream>
using namespace std;
#include <cmath>
int main() {
	string s,g;
	cin>>s>>g;
	string arr[7]={"monday","tuesday","wednesday","thursday","friday","saturday","sunday"};
	int a=0,b=0;
	for(int i=0;i<7;i++){if(arr[i]==s)a=i; if(arr[i]==g)b=i;}
	int t=0;
	t=(b-a);
	if(t<0) t=7-abs(t);
	t=t+28;
	if(t==28||t==30||t==31) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	// your code goes here
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define pb push_back

int main()
{
    map<string,int>mp;
    mp["monday"]=1;
    mp["tuesday"]=2;
    mp["wednesday"]=3;
    mp["thursday"]=4;
    mp["friday"]=5;
    mp["saturday"]=6;
    mp["sunday"]=0;

    string s,p;
    vector<int>v[10];
    cin>>s>>p;
    for(int i=0;i<7;i++)
    {
        v[i].pb((i+7)%7);
        v[i].pb((i+3)%7);
        v[i].pb((i+2)%7);
    }
    int k=mp[s];
    int l=mp[p];
   // cout<<k<<" "<<l<<"\n";
    int c=0;
    for(int i=0;i<v[k].size();i++)
    {
        //cout<<v[k][i]<<" ";
        if(v[k][i]==l)
        {
            c=1;
            break;
        }
    }
    if(c==0)
        cout<<"NO";
    else
        cout<<"YES";
}

#include<bits/stdc++.h>
using namespace std;
map<string,int>mp;
int main(){
    mp["monday"]=1;mp["tuesday"]=2;mp["wednesday"]=3;mp["thursday"]=4;mp["friday"]=5;
    mp["saturday"]=6;mp["sunday"]=7;
    string a,b;
    cin>>a>>b;
    int sum=(mp[b]-mp[a]);
    if(sum<0) sum+=7;
    //cout<<sum<<endl;
    if(sum==2||sum==3|| sum==0) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

#include<bits/stdc++.h>
using namespace std;

string dict[] = {"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};

int main(){
    string s1 ,s2;
    int x, y;
    cin >> s1 >> s2;
    for(int i = 0 ;i < 7 ; i++) if(dict[i] == s1) x = i;
    for(int i = 0 ;i < 7 ; i++) if(dict[i] == s2) y = i;
    if(x == y || (x+2)%7 == y|| (x+3)%7 == y)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

/*F-Checking the Calendar*/
#include<iostream>
#include<sstream>
#include<fstream>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<ctime>
#include<iomanip>
#include<complex>
#include<climits>
#define re register
#define in inline
#define pi acos(-1.0)
#define inf 2147483640
using namespace std;
in int read()
{
    int sum=0,negative=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')negative=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        sum=sum*10+ch-'0';
        ch=getchar();
    }
    return sum*negative;
}
in void write(int X)
{
    if(X<0)putchar('-'),X=-X;
    if(X>=10)write(X/10);
    putchar(X%10+'0');
}
map<string,int>m;
char a[15],b[15];
int day[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
void init(){
	m["monday"]=1;
	m["tuesday"]=2;
	m["wednesday"]=3;
	m["thursday"]=4;
	m["friday"]=5;
	m["saturday"]=6;
	m["sunday"]=7;
}
void scan(){
	scanf("%s%s",a,b);
}
void judge(){
	int res=(m[b]-m[a]+7)%7;
	for(re int i=1;i<=12;i++){
		if(day[i]%7==res){
			puts("YES");
			return;
		}
	}
	puts("NO");
	return;
}
int main()
{
	ios::sync_with_stdio(false);
	init();
	scan();
	judge();
    return 0;
}

#include<iostream>
using namespace std;
int main(){
    string a[7]={"monday","tuesday", "wednesday", "thursday", "friday", "saturday", "sunday" },b,c;
    cin>>b>>c;
    for(int i=0;i<7;i++){
    	if(b==a[i]){
    		for(int j=0;j<7;j++){
    			if(c==a[j]){
    				if(i==j||j==i+2||j==i-5||j==i+3||j==i-4)cout<<"YES";
    				else cout<<"NO";
				}
			}
		}
	}
}

#include <cmath>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <map>
#include <vector>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  map<string, int> a;
  a["monday"] = 0;
  a["tuesday"] = 1;
  a["wednesday"] = 2;
  a["thursday"] = 3;
  a["friday"] = 4;
  a["saturday"] = 5;
  a["sunday"] = 6;
  string s1, s2;
  cin >> s1 >> s2;
  int a1 = a[s2] - a[s1];
  if (a1 == 1 || a1 == -1 || a1 == 6 || a1 == -6 || (a1 >= 4 && a1 > 0) || (a1 >= -3 && a1 < 0)) {
    cout << "NO\n" ;
  } else {
    cout << "YES\n";
  }
  return 0;
}

#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

typedef unsigned uint;
typedef long long lint;
typedef unsigned long long ulint;
typedef long double ldouble;
typedef complex<double> point;

const double E=1e-9, pi=2*acos(0);
const ldouble PI=2*acosl(0);

map<string, int> value;
vector<string> days={"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};
vector<int> months={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30};

bool solve(int testNumber) {
	string A, B;
	if (!(cin>>A>>B)) return false;
	int v1=value[A], v2=value[B], delta=(v2-v1+7)%7;
	bool valid=false;
	for (int i: months) valid|=i==delta;
	printf("%s\n", valid?"YES":"NO");
	return true;
}

void init() {
	for (int i=0; i<7; i++) value[days[i]]=i;
	for (int &i: months) i%=7;
}

int main() {
	init();
	for (int i=1; solve(i); i++);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
   char s1[15],s2[15];
   char s[7][15]={"monday","tuesday","wednesday","thursday","friday","saturday","sunday"};
   int a[]={31,28,31,30,31,30,31,31,30,31,30,31};
   int i,k,m;
   cin>>s1>>s2;
   for(i=0;i<7;i++)
   {
   	if(strcmp(s[i],s1)==0)
   	{
   		k=i+1;
	   }
	   if(strcmp(s[i],s2)==0)
	   {
	   	m=i+1;
	   }
   }
int flag=0,temp,p;
   for(i=0;i<11;i++)
   {
     temp=a[i]%7;
     if(k+temp==7)
     {
     	p=k+temp;
	 }
	 else
	 {
	 	p=(k+temp)%7;
	 }
     if(p==m)
       {   cout<<"YES"<<endl;
           flag=1;
            break;}
    }
if(flag==0)
  cout<<"NO"<<endl;
return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
char s[2][15];
int main()
{
    while(scanf("%s%s",s[0],s[1])!=EOF)
    {
        int n[2];
        for(int i=0;i<2;i++)
        {
            int l=strlen(s[i]);
            if(l==6)
            {
                if(strcmp("monday",s[i])==0)  n[i]=1;
                else if(strcmp("friday",s[i])==0) n[i]=5;
                else n[i]=0;
            }
            else if(l==7)  n[i]=2;
            else if(l==8)
            {
                if(strcmp("thursday",s[i])==0) n[i]=4;
                else n[i]=6;
            }
            else n[i]=3;
        }
        int t=n[0]+28;
        if(t%7==n[1])
        {
            printf("YES\n");
            continue;
        }
        t=n[0]+30;
        if(t%7==n[1])
        {
            printf("YES\n");
            continue;
        }
        t=n[0]+31;
        if(t%7==n[1])
        {
            printf("YES\n");
            continue;
        }
        else printf("NO\n");
    }
    return 0;
}

#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

#define endl '\n'

struct ddate
{
    int weekday;
    int month;
    int year;
    ddate(){}
    ddate(int w, int m, int y):weekday(w), month(m), year(y){}
    ~ddate(){}
};

int main(int argc, char* argv[])
{
    vector<ddate> weekdays;
    cin.tie(0);
    ios::sync_with_stdio(false);
    string weekday1, weekday2; cin >> weekday1; cin >> weekday2;
    int wkd1, wkd2;
    if (weekday1 == "monday") wkd1 = 1;
    else if (weekday1 == "tuesday") wkd1 = 2;
    else if (weekday1 == "wednesday") wkd1 = 3;
    else if (weekday1 == "thursday") wkd1 = 4;
    else if (weekday1 == "friday") wkd1 = 5;
    else if (weekday1 == "saturday") wkd1 = 6;
    else if (weekday1 == "sunday") wkd1 = 7;
    if (weekday2 == "monday") wkd2 = 1;
    else if (weekday2 == "tuesday") wkd2 = 2;
    else if (weekday2 == "wednesday") wkd2 = 3;
    else if (weekday2 == "thursday") wkd2 = 4;
    else if (weekday2 == "friday") wkd2 = 5;
    else if (weekday2 == "saturday") wkd2 = 6;
    else if (weekday2 == "sunday") wkd2 = 7;

    int weekday = 1;//1.1.2001 is monday
    int year = 2001;
    int month = 1;
    int day = 1;

    while (1)
    {
        //cout << day << "." << month << "." << year << "   " << weekday << endl;
        if ((day == 1) && ((year%4) != 0)) weekdays.push_back(ddate(weekday, month, year));
        weekday += 1; if (weekday == 8) weekday = 1;
        day += 1;
        if ((month == 2) && (year%4 != 0) && (day == 29))
        {
            month += 1;
            day = 1;
        }
        else if ((month == 2) && (year%4 == 0) && (day == 30))
        {
            month += 1;
            day = 1;
        }
        else if (((month == 4) || (month == 6) || (month == 9) || (month == 11)) && (day == 31))
        {
            month += 1;
            day = 1;
        }
        else if (((month == 1) || (month == 3) || (month == 5) || (month == 7) || (month == 8) ||
                (month == 10) || (month == 12)) && (day == 32))
        {
            month += 1;
            day = 1;
            if (month == 13)
            {
                month = 1;
                year += 1;
            }
        }
        if (year == 2017) break;
    }
    vector<ddate>::iterator i = weekdays.begin();
    vector<ddate>::iterator im = weekdays.begin();
    ++i;
    for (; i != weekdays.end(); ++i,++im)
    {
        if (((*i).weekday == wkd2) && ((*im).weekday == wkd1) && ((*im).year == (*i).year))
        {
            cout << "YES";
            return 0;
        }
    }
    cout << "NO";
    return 0;
}

#include<iostream>

using namespace std;

void dayToNumber(string day, int &number)
{
    if(day == "monday")
        number = 1;
    else if(day == "tuesday")
        number = 2;
    else if(day == "wednesday")
        number = 3;
    else if(day == "thursday")
        number = 4;
    else if(day == "friday")
        number = 5;
    else if(day == "saturday")
        number = 6;
    else if(day == "sunday")
        number = 7;
}

int main()
{
    string x1; string x2; cin>>x1; cin>>x2; int day1, day2; dayToNumber(x1, day1); dayToNumber(x2, day2); int y = 0;
    if(day2 > day1)
        y = day2 - day1;
    else if(day1 > day2)
        y = 7 - day1 + day2;
    if(y == 3 || y == 2 || y == 0)
        cout<<"YES";
    else
        cout<<"NO";
    return 0;
}

#include<bits/stdc++.h>

using namespace std;

int f(string m)
{
    if(m=="monday") return 1;
    if(m=="tuesday") return 2;
    if(m=="wednesday") return 3;
    if(m=="thursday") return 4;
    if(m=="friday") return 5;
    if(m=="saturday") return 6;
    if(m=="sunday") return 7;
}

int main()
{
    string x,y;
    cin >> x >> y;
    int c=f(y)-f(x);
    c+=7;
    c%=7;
    if((c==0)||(c==2)||(c==3))
    {
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
}

// IN THE NAME OF ALLAH
#include <math.h>
#include <vector>
#include <set>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include<cstring>
#include <cstdlib>
#include <string>
#include <ctime>
#include <cstdio>
#include <cmath>

#define int ll

#define F first
#define S second
#define mp make_pair
#define Left(x) (2*(x))
#define Right(x) ((2*(x))+1)
#define pii pair<int , int>

using namespace std;
typedef long long ll;

const int N = 2e6 + 5 , MOD = 2 , MAXN = 1e5 , LG = 20 , M = 1e6 + 5 , P = 727 , Sq = 100;
const ll inf = 1e18 + 10;

int f[N] , mark[N];
vector<int> v;

int32_t main(){
      string s , t;
      int tmp1 = 0 , tmp2 = 0;
      cin>>s>>t;
      string a[7] = {"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};
      for(int i = 1 ; i <= 7 ; i++)
            if(s == a[i])
                  tmp1 = i;
      for(int i = 1 ; i <= 7 ; i++)
            if(t == a[i])
                  tmp2 = i;
      int mm[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
      if(tmp2 == tmp1 || tmp2 == (tmp1 + 2) % 7 || tmp2 == (tmp1 + 3) % 7)
            return cout<<"YES" , 0;
      return cout<<"NO" , 0;
}

#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define xin
int  dear( char ss[])
{
	 if(ss[0]=='m')  return 1;
	 else if(ss[0]=='t'){
	       if(ss[1]=='u')
			  return 2;
		   else return 4;
	 }
	 else if(ss[0]=='w')
		 return 3;
	 else if(ss[0]=='f')
		 return 5;
	 else if(ss[0]=='s')
		 if(ss[1]=='a')
			 return 6;
		 else return 7;
}
int main(){
#ifdef xi
	freopen("1.txt","r",stdin);
#endif

	int s[]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	int g[13];
	g[0]=1;
	int sum=s[0];
	for(int a=0;a<11;a++)
	{
	  g[a+1]=sum%7+1;
	  sum+=s[a+1];
	}
	//for(int a=0)
	//cout<<g[1]<<endl;
	char s1[10],s2[10];
     cin>>s1>>s2;
	  int aa=dear(s1);
	  int bb=dear(s2);
	  int cc=0;
	  while(aa!=bb)
	  {
	      aa++;
		  if(aa>7) aa=aa%7;
		  cc++;
	  }

	  for(int a=0;a<11;a++){
		   aa=g[a]; bb=g[a+1];
		//   cout<<aa<<" "<<bb<<endl;
		   int dd=0;
		  while(aa!=bb) {
	      aa++;
		  if(aa>7) aa=aa%7;
	 	  dd++;
	    }
		 // cout<<dd<<" ";
		  if(cc==dd)
		 {
			  printf("YES\n");
			  return 0 ;
		 }
	  }
    printf("NO\n");

	return 0;
}

#include<bits/stdc++.h>
#define int long long int
#define SHUKRIYAA ios_base::sync_with_stdio(false);  cin.tie(NULL);  cout.tie(NULL);
using namespace std;

signed main()
{
	SHUKRIYAA ;
	int month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	string week[] = { "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};
	string a,b;
	cin>>a>>b;
	int aa,bb;
	for(int i=0;i<7;i++)
	{
		if(week[i]==a)
			aa = i;
		if(week[i]==b)
			bb = i;
	}
	for(int i=0;i<11;i++)
	{
		if(week[(aa+month[i])%7]==b)
			return cout<<"YES", 0;
	}
	cout<<"NO";
}

#include <cstring>
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
	string s1;
	string s2;
	cin>>s1;
	cin>>s2;
	if(s1==s2) puts("YES");
	else
	{
		if(s1=="sunday")
		{
			if(s2=="wednesday"||s2=="tuesday") puts("YES");
			else puts("NO");
		}
		if(s1=="monday")
		{
			if(s2=="thursday"||s2=="wednesday") puts("YES");
			else puts("NO");
		}

		if(s1=="tuesday")
		{
			if(s2=="friday"||s2=="thursday") puts("YES");
				else puts("NO");

		}
		if(s1=="wednesday")
		{	if(s2=="saturday"||s2=="friday") puts("YES");
			else puts("NO");}
		if(s1=="thursday"){
			if(s2=="sunday"||s2=="saturday") puts("YES");
			else puts("NO");
		}

		if(s1=="friday"){
			if(s2=="sunday"||s2=="monday") puts("YES");
			else puts("NO");
		}

		if(s1=="saturday"){
			if(s2=="tuesday"||s2=="monday") puts("YES");
			else puts("NO");
		}

	}
	return 0;
}

#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>

int a,b,c;
string d,d2;
map<string,int>m;

bool f(int n)
{
	c=a;
	for(int i=1;i<=n;i++)c++;
	if(c%7==b)
	{
		cout<<"YES\n";
		return 1;
	}
	return 0;
}

void solve()
{
	m["saturday"]=0;
	m["sunday"]=1;
    m["monday"]=2;
	m["tuesday"]=3;
	m["wednesday"]=4;
	m["thursday"]=5;
	m["friday"]=6;
	cin>>d>>d2;
	a=m[d];
	b=m[d2];
	if(f(31))return;
	if(f(28))return;
	for(int i=3;i<=7;i++)
	{
		if(i%2==1)
		{
			if(f(31))return;
		}
		else
		{
			if(f(30))return;
		}
	}
	for(int i=8;i<=11;i++)
	{
		if(i%2==1)
		{
			if(f(30))return;
		}
		else
		{
			if(f(31))return;
		}
	}
	cout<<"NO\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
	solve();
	return 0;
}

#include<iostream>
#include<string.h>
#include<stdio.h>
using namespace std;
int a[366],d,g,i,j,ti,u;
char b[15],c[15];

int main()
{   int n=0,m=0;

    for(i=0;i<15;i++)
    {
        if(b[i-1]!='y')
        cin >> b[i];
        else break;
    }
    i=0;
    for(i=0;i<15;i++)
    {
        if(c[i-1]!='y')
        {cin >> c[i];
        }
        else break;
    }
    char mo[]="monday";
    char t[]="tuesday";
    char w[]="wednesday";
    char th[]="thursday";
    char f[]="friday";
    char st[]="saturday";
    char sn[]="sunday";

    if(strcmp(b,mo)==0)
        n=1;
    else if(strcmp(b,t)==0)
        n=2;
    else if(strcmp(b,w)==0)
        n=3;
    else if(strcmp(b,th)==0)
        n=4;
    else if (strcmp(b,f)==0)
        n=5;
    else if (strcmp(b,st)==0)
        n=6;
    else if (strcmp(b,sn)==0)
        n=7;

   if(strcmp(c,mo)==0)
        m=1;
    else if(strcmp(c,t)==0)
        m=2;
    else if(strcmp(c,w)==0)
        m=3;
    else if(strcmp(c,th)==0)
        m=4;
    else if (strcmp(c,f)==0)
        m=5;
    else if (strcmp(c,st)==0)
        m=6;
    else if (strcmp(c,sn)==0)
        m=7;

    for(u=1;u<=7;u++)
    {  ti=u;
        for(i=1;i<366;i++)
        {
            a[i]=ti;
            ti++;

            if(ti==8)
                ti=1;
        }
        if(a[1]==n && a[32]==m)
            {g=1;
            break;
            }
        else if (a[32]==n && a[60]==m)
            {g=1;
            break;
            }
        else if(a[60]==n && a[91]==m)
            {g=1;
            break;
            }
        else if(a[91]==n && a[121]==m)
            {g=1;
            break;}
        else if(a[121]==n &&a[152]==m)
            {g=1;
            break;
            }
        else if(a[152]==n && a[182]==m)
            {g=1;
            break;
            }
        else if(a[182]==n&& a[213]==m)
            {g=1;
            break;
            }
        else if(a[213]==n&& a[244]==m)
            {g=1;break;}

        else if (a[244]==n && a[274]==m)
            {g=1;
            break;
            }
        else if(a[274]==n&& a[305]==m)
            {g=1;
            break;
            }
        else if(a[305]==n && a[335]==m)
            {g=1;
            break;
            }

        else d++;

    }
    if(d!=7)
        cout<<"YES";
    else
        cout<<"NO";

}

#include<bits/stdc++.h>
#define up(j,k,i) for(i=j;i<k;i++)
#define down(j,k,i) for(i=j;i>k;i--)
#define pp(n) printf("%lld\n",n)
#define is(n) scanf("%lld",&n)
#define ips(n) scanf("%lld",n)
#define ss(s) scanf("%s",s)
#define cool 0
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define f(i) cout<<i<<endl;
#define pll pair<lld,lld>
#define pi acos(-1)
#define ds(n,m) scanf("%lld %lld",&n,&m)
#define ts(n,m,k) scanf("%lld %lld %lld",&n,&m,&k)
typedef long double ld;
typedef long long int lld;
using namespace std;
const lld M =1e18+7;
const lld mod=1e9+7;
const lld infi =1e18+7;
lld a[]={ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
map <string ,lld> cnt;
int main()
{
cnt[ "monday"]=1;
cnt["tuesday"]=2;
cnt["wednesday"]=3;
 cnt["thursday"]=4;
 cnt["friday"]=5;
 cnt[ "saturday"]=6;
 cnt ["sunday"]=0;
        lld i,j,ans=0;
        string a1,b;
        cin>>a1>>b;
        lld na=cnt[a1],nb=cnt[b];
        na=nb-na;
        na+=7;
        na=na%7;
        up(0,11,i)
        {
          ans=a[i];
          if(ans%7==(na))
          {
            cout<<"YES\n";
            return 0;
          }
        }
        cout<<"NO\n"
;        return 0;
}

#include <iostream>
#include <string>
#include <map>
using namespace std;
int main()
{
	map<string, int> m;
	m.insert(pair<string, int>("monday", 1));
	m.insert(pair<string, int>("tuesday", 2));
	m.insert(pair<string, int>("wednesday", 3));
	m.insert(pair<string, int>("thursday", 4));
	m.insert(pair<string, int>("friday", 5));
	m.insert(pair<string, int>("saturday", 6));
	m.insert(pair<string, int>("sunday", 7));
	string s1, s2;
	int a, b;
	cin >> s1 >> s2;
	a = m[s1], b = m[s2];
	if(m[s1] > m[s2]){
		b += 7;
	}
	if((b - a) == 0 || (b - a) == 2 || (b - a) == 3){
		cout << "YES";
	}
	else{
		cout << "NO";
	}
	return 0;
}

// In the name of Allah.
// We're nothing and you're everything.
// Ya Ali!

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int maxn = 2e5 + 14;

int n;
string names[] = {"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};
int main(){
    ios::sync_with_stdio(0), cin.tie(0);
    string f, s;
    cin >> f >> s;
    int i = find(names, names + 7, f) - names;
    int j = find(names, names + 7, s) - names;
    cout << (i == j || (i + 2) % 7 == j || (i + 3) % 7 == j ? "YES" : "NO") << '\n';
}

#include <iostream>
#include <string>
#include <cmath>

using namespace std;
string day[14]={"monday", "tuesday", "wednesday", "thursday","friday", "saturday", "sunday","monday", "tuesday", "wednesday", "thursday","friday", "saturday", "sunday"};

int ind(string ch)
{

    for(int i=0;i<7;i++)
    {
        if(day[i]==ch)
        {
            return i;
            break;
        }
    }
}

int main()
{
    string d1,d2;
    int a,b;
    cin >> d1;
    cin >> d2;
    a=ind(d1);
    b=ind(d2);
    if(day[a]==day[b]) {cout << "YES";}
    else   {if(day[a]==day[b+5]) {cout << "YES";}
           else {if (day[a]==day[b+4]) {cout << "YES";}
                 else {cout << "NO";}
           }
    }

    return 0;
}

#include<iostream>
using namespace std;
const string days[]={"monday","tuesday","wednesday","thursday","friday","saturday","sunday"};
const int months[]={31,28,31,30,31,30,31,31,30,31,30,31};
int main()
{
 int i,reg,check;
 string s1,s2;
 cin>>s1>>s2;
 for(i=0;i<7;i++)

     if(s1==days[i])
      {
    reg=i;
     break;
 }
    if(s2==days[(reg+0)%7]||s2==days[(reg+2)%7]||s2==days[(reg+3)%7])
        {cout<<"YES"<<endl;
        return 0;
        }
                cout<<"NO"<<endl;
               return 0;
}

#include<iostream>
using namespace std;
const string days[]={"monday","tuesday","wednesday","thursday","friday","saturday","sunday"};
const int months[]={31,28,31,30,31,30,31,31,30,31,30,31};
int main()
{
 int i,reg,check;
 string s1,s2;
 cin>>s1>>s2;
 for(i=0;i<7;i++)

     if(s1==days[i])
      {
    reg=i;
     break;
 }
 for(i=0;i<12;i++)
 { check=months[i]%7;
    if(s2==days[(reg+check)%7])
        {cout<<"YES"<<endl;
              return 0;
        }
 }
 cout<<"NO"<<endl;
}

#include<iostream>
#include<stdio.h>
#include<map>
using namespace std;
bool comp(pair<int,int> a,pair<int,int> b){
	if((a.first == b.first) && (a.second == b.second)) return true;
	if((a.first == b.second) && (a.second == b.first)) return true;
	return false;
}
int func(int a){
	if (a > 7) return a%7;
	return a;
}
int main(){
int yil = 2017;
int kun = 365;
int month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int i=1;
int haftakun=1;
pair<int,int> t, t1;
map<string,int> hafta;
	hafta["monday"] = 1;
	hafta["tuesday"] = 2;
	hafta["wednesday"] = 3;
	hafta["thursday"] = 4;
	hafta["friday"] = 5;
	hafta["saturday"] = 6;
	hafta["sunday"] = 7;
string a;
cin>>a;
t1.first = hafta[a];
cin>>a;
t1.second = hafta[a];

while(i<=yil){
	for (int j=0; j<12; j++){
		t.first = haftakun;
		haftakun += month[j]%7;
		haftakun = func(haftakun);
		t.second = haftakun;

		if (comp(t1,t)){
			cout<<"YES";
			return 0;
		}
	};

	i++;
}
cout<<"NO";
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main(){
	string a , b , c , d  ;
	int x , y , z ,e ;
	cin>> a >> b ;
	if( a == "sunday" ){
		x = 2;
	}
	if( a == "monday"){
		x = 3 ;
	}
	if( a == "tuesday" ){
		x = 4 ;
	}
	if( a == "wednesday" ){
		x = 5 ;
	}
	if( a == "thursday" ){
		x = 6 ;
	}
	if( a == "friday" ){
		x = 7 ;
	}
	if( a == "saturday" ){
		x = 1 ;
	}
	if(b == "sunday" ){
		y = 2;
	}
	if( b == "monday"){
		y = 3 ;
	}
	if( b == "tuesday" ){
		y = 4 ;
	}
	if( b == "wednesday" ){
		y = 5 ;
	}
	if( b == "thursday" ){
		y = 6 ;
	}
	if( b == "friday" ){
		y = 7 ;
	}
	if( b == "saturday" ){
		y = 1 ;
	}
		if( b == "friday" && a == "wensday"){
		cout<< "NO" ;
		return 0 ;
	}
	if( a == "friday" && b == "wensday"){
		cout<< "NO" ;
		return 0 ;
	}
	e = abs ( x - y ) ;
	if( e == 2 || e == 3 || e == 0){
		cout<<"YES" ;
	}
	else {
		cout<<"NO" ;
	}

}

#include<iostream>
#include<cmath>
using namespace std;
int a,b;
string n,m;
int main(){
	cin>>n;
	if(n=="monday")a=1;
	else if(n=="tuesday")a=2;
	else if(n=="wednesday")a=3;
	else if(n=="thursday")a=4;
	else if(n=="friday")a=5;
	else if(n=="saturday")a=6;
	else if(n=="sunday")a=7;
	cin>>m;
	if(m=="monday")b=1;
	else if(m=="tuesday")b=2;
	else if(m=="wednesday")b=3;
	else if(m=="thursday")b=4;
	else if(m=="friday")b=5;
	else if(m=="saturday")b=6;
	else if(m=="sunday")b=7;
	if(abs(a-b)%7==0||abs(a-b)%7==2||abs(a-b)%7==3)cout<<"Yes";
	else cout<<"No";
}

// Problem : A. Checking the Calendar
// Contest : Codeforces - Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined)
// URL : https://codeforces.com/problemset/problem/724/A
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define int         long long int
#define vi           vector<int>
#define pii          pair<int,int>
#define vpp          vector<pii>
#define mii          map<int,int>
#define pb           push_back
#define endl        '\n'
#define rep(i,a,bb)  for(int i=a;i<bb;i++)
#define ff           first
#define ss           second
#define fast         ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test         int T;cin>>T;while(T--)
#define __sort(v)    sort(v.begin(),v.end())
#define __rsort(v)   sort(v.rbegin(),v.rend())
#define setbits(x)   __builtin_popcount(x)
#define zrobits(x)   __builtin_ctzint(x)
const int inf = 5 * (1e+8);
const int mod = 1e+9 + 7;
#define ll long long
vector<int> adj[500005];
vector<int> visited(500005, 0);
vector<int> t(500005, 0);
int flag = 1;
void nothing()
{

}

		void solve()
		{
			string s1,s2;
			cin>>s1>>s2;
			map<string, int> week;
			week["monday"]=0;
			week["tuesday"]=1;
			week["wednesday"]=2;
			week["thursday"]=3;
			week["friday"]=4;
			week["saturday"]=5;
			week["sunday"]=6;
			int n=abs(week[s2]-week[s1]);
			if(n==3||n==0||n==2||n==4||n==5)
			cout<<"YES"<<endl;
			else
			cout<<"NO"<<endl;
		}
		int32_t main()
		{
			fast;
			solve();
			return 0;
		}

#define mm(a) memset(a,0,sizeof(a));
#define max(x,y) (x)>(y)?(x):(y)
#define min(x,y) (x)<(y)?(x):(y)
#define Fopen freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,b,a) for(int i=(b);i>=(a);i--)
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int INF=0x3f3f3f3f;
const int MAXN=405;//vertex
const int MAXM=1005;//edge
int n;
map<string,int>mp;
string a,b;
int main()
{
//    printf("%d\n",29%7);
    mp["monday"]=0;
    mp["tuesday"]=1;
    mp["wednesday"]=2;
    mp["thursday"]=3;
    mp["friday"]=4;
    mp["saturday"]=5;
    mp["sunday"]=6;
    cin>>a>>b;
    int temp=mp[b]-mp[a];
    temp%=7;
    temp+=7;
    temp%=7;
    if(temp!=1)puts("YES");
    else puts("NO");
    return 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define FBO find_by_order
#define OOK order_of_key

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int getDay(string s)
{
	///"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"
	if(s == "monday")
		return 0;
	if(s == "tuesday")
		return 1;
	if(s == "wednesday")
		return 2;
	if(s == "thursday")
		return 3;
	if(s == "friday")
		return 4;
	if(s == "saturday")
		return 5;
	if(s == "sunday")
		return 6;
	return 0;
}
void swap(int *p , int *q)
{int temp ; temp = *p ; *p = *q ; *q = temp;return;}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
    string s1,s2;
    int i1,i2;
    cin >> s1>>s2;
    i1 = getDay(s1);
    i2 = getDay(s2);

    if(((i1+1)%7 == i2) || (i2+1)%7 == i1 )
		cout << "NO" << endl;
	else
	cout << "YES" << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

void determine(string x,int& a)
{
    if(x=="monday")
    {
        a=1;
    }
    else if(x=="tuesday")
    {
        a=2;
    }
    else if(x=="wednesday")
    {
        a=3;
    }
    else if(x=="thursday")
    {
        a=4;
    }
    else if(x=="friday")
       {
           a=5;
       }
       else if(x=="saturday")
       {
           a=6;
       }
       else
       {
           a=7;
       }

}
void se(int x,int& x1,int& x2)
{
    if(x>5)
    {
        x1=(x+2)%7;
    }
    else
    {
        x1=x+2;
    }
    if(x>=5)
    {
        x2=(x+3)%7;
    }
    else
    {
        x2=(x+3);
    }
}

int main()
{
   string s1;
   string s2;
   cin>>s1;
   cin>>s2;
   int x,y,x1,y1,x2,y2;
   determine(s1,x);
   determine(s2,y);
   se(x,x1,x2);
   se(y,y1,y2);

   if(x==y||x1==y||x2==y||y1==x||y2==x)
   {
       cout<<"YES";
   }
   else
   {
       cout<<"NO";
   }

}

#include <bits/stdc++.h>
using namespace std;

int day(string s){
    if(s[0]=='m') return 0;
    if(s[0]=='t' && s[1]=='u') return 1;
    if(s[0]=='w') return 2;
    if(s[0]=='t' && s[1]=='h') return 3;
    if(s[0]=='f') return 4;
    if(s[0]=='s' && s[1]=='a') return 4;
    if(s[0]=='s' && s[1]=='u') return 5;
    return -1;
}

int main()
{
#ifdef gsdt
    freopen("input.txt","r",stdin);
#endif // gsdt
    int month[12]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    int a,b;
    string s;
    cin>>s; a=day(s);
    cin>>s; b=day(s);

    for(int i=1; i<12; i++){
        int t=month[i-1]; t%=7; t++;
        if(abs(a-b+1)==t%7) return cout<<"YES", 0;
    }
    cout<<"NO";
    return 0;
}

#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<time.h>
#include<stdlib.h>
#include<stdio.h>
#include<map>
#include<math.h>
#define intt long long
using namespace std;
struct code
{
    int x,y,ind;
};
int64_t check(int x)
{
    return 1;
}
int n,m;
int a[1000001];
int b[1000001];
int ok,cnt,sum;
vector<int>p;
int used[1000];
string w[]={"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};
bool is_leap(int nowy)
{
    return (nowy%4==0 and nowy%100!=0) or nowy%400==0;
}
main()
{
    string s1,s2;
    cin>>s1>>s2;
    int w1,w2;
    for(int i=0;i<7;i++)
    {
        if(s1==w[i]) w1=i+1;
        if(s2==w[i]) w2=i+1;
    }

    int nowd=8,nowm=10,nowy=2016;
    int week=6,lastweek=1e9;
    while(nowy!=1e5)
    {
        nowd++;
//        cout<<nowd<<" "<<nowm<<" "<<nowy<<endl;
        if(nowm==1 or nowm==3 or nowm==5 or nowm==7 or nowm==8 or nowm==10 or nowm==12)
        {
            if(nowd==32)
            {
                nowd=1;
                nowm++;
                if(nowm==13)
                {
                    nowm=1;
                    nowy++;
                }
            }
        }
        else if(nowm==2)
        {
            if(nowd==29 and !is_leap(nowy))
            {
                nowd=1;
                nowm++;
            }
            else if(nowd==30 and is_leap(nowy))
            {
                nowd=1;
                nowm++;
            }
        }
        else
        {
            if(nowd==31)
            {
                nowd=1;
                nowm++;
            }
        }
        week++;
        if(week==8)
        {
            week=1;
        }
        if(nowd==1)
        {
            if(lastweek==w1 and week==w2)
            {
                cout<<"YES";
                return 0;
            }
            lastweek=week;
        }

    }
    cout<<"NO";
}

#include<bits/stdc++.h>

using namespace std;

map<string,int> m;

int main()
{
    ios::sync_with_stdio(false);

    m["monday"] = 1;
    m["tuesday"] = 2;
    m["wednesday"] = 3;
    m["thursday"] = 4;
    m["friday"] = 5;
    m["saturday"] = 6;
    m["sunday"] = 7;

    string a,b;
    int s;

    cin >> a >> b;

    s = m[b] - m[a];

    if(s == 0 || s == 2 || s == 3)
    {
        cout << "YES" << endl;

        return 0;
    }
    else
    {
        cout << "NO" << endl;

        return 0;
    }
}

#include <stdio.h>
#include <string.h>
const char* msg[] = { "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"  };
int main()
{
	char a[ 10 ], b[ 10 ];
	int ma, mb;
	while ( ~scanf( "%s\n%s", a, b ) )
	{
		ma = 0, mb = 0;
		//printf( "%s%s%s\n", a, b, msg[ 0 ] );
		for ( int i = 0; i < 7; i++ )
		{
			if ( strcmp( a, msg[ i ] ) == 0 )
				ma = i;
			if ( strcmp( b, msg[ i ] ) == 0 )
				mb = i;
		}
		int ans = ma - mb;
		//printf( "%d%d%d\n", ma, mb, ans );
		if ( ans == 2 || ans == 0 || ans == 4 || ans == -3 || ans == -2 || ans == 5 )
			printf( "YES\n" );
		else
			printf( "NO\n" );
	}
}

#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<vector>
using namespace std;

#define csl ios_base::sync_with_stdio(false);cin.tie(NULL);
const int N = 100005;

int main()
{
    csl;
    int i;
    string a,b;
    cin>>a>>b;
    string v[8];
    v[0] = "monday";
    v[1] = "tuesday";
    v[2] = "wednesday";
    v[3] = "thursday";
    v[4] = "friday";
    v[5] = "saturday";
    v[6] = "sunday";
    for(i=1;i<=7;i++)
        if(v[i]==a)
            break;
    if(v[i]==b || v[(i+2)%7]==b || v[(i+3)%7]==b)
        cout<<"YES";
    else
        cout<<"NO";
    return 0;
}

#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <cmath>

using namespace std;

string days[] = {"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};
int avds[] = {30, 31, 28};

int main() {
    map<string, int> dayMap;
    for (int i=0; i<7; i++) {
        dayMap[days[i]] = i;
    }
    string dd1;
    string dd2;
    cin >> dd1;
    cin >> dd2;
    int d1 = dayMap[dd1];
    int d2 = dayMap[dd2];
    for (int i=0; i<3; i++) {
	int mod = avds[i] % 7;
	int sub = d1 < d2 ? d2 - d1 : d1 - d2;
        if (mod == sub) {
            cout << "YES";
            return 0;
        }
    }
    cout << "NO";
}

#include <bits/stdc++.h>
using namespace std;

int day(string s){
    if(s[0]=='m') return 0;
    if(s[0]=='t' && s[1]=='u') return 1;
    if(s[0]=='w') return 2;
    if(s[0]=='t' && s[1]=='h') return 3;
    if(s[0]=='f') return 4;
    if(s[0]=='s' && s[1]=='a') return 4;
    if(s[0]=='s' && s[1]=='u') return 5;
    return -1;
}

int main()
{
#ifdef gsdt
    freopen("input.txt","r",stdin);
#endif // gsdt
    int month[12]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    int a,b;
    string s;
    cin>>s; a=day(s);
    cin>>s; b=day(s);

    for(int i=1; i<12; i++){
        int t=month[i-1]+1; t%=7;
        if(abs(a-b+1)==t) return cout<<"YES", 0;
    }
    cout<<"NO";
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int i,ans,ans1,ans2;
string s,s1,w[7];
int main()
{
    w[0]="monday"; w[1]="tuesday"; w[2]="wednesday"; w[3]="thursday"; w[4]="friday"; w[5]="saturday"; w[6]="sunday";
    cin>>s>>s1;
    for(i=0;i<7;i++)
        if(w[i]==s)
            ans1=i;
    for(i=0;i<7;i++)
        if(w[i]==s1)
            ans2=i;
    ans=abs(ans1-ans2);
    if(ans==0 || ans==3 || ans==4)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}

#include <iostream>

using namespace std;

int main()
{
	int i;
	string S,s,m,T,w,t,f,q,a,b;
	string str1,str2;
	cin>>str1>>str2;
	q="SsmTwtfSsm";
	if(str1=="saturday" or str1=="tuesday"){
		a="abcdefghijklmnopqrstuvwxyz";
		b="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		for(i=0;i<26;i++){
			if(a[i]==str1[0]){
				str1=b[i];
			}
		}
	}
	if(str2=="saturday" or str2=="tuesday"){
		for(i=0;i<26;i++){
			if(a[i]==str2[0]){
				str2=b[i];
			}
		}
	}
	if(str1=="sunday" and str2=="S"){
		cout<<"NO";
		return 0;
	}
	for(i=0;i<7;i++){
		if(str1[0]==q[i] and (str2[0]==q[i] or str2[0]==q[i+2] or str2[0]==q[i+3])){
			cout<<"YES";
			return 0;
		}
	}
	cout<<"NO";
}

#include<bits/stdc++.h>
using namespace std ;

int day[]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main()
{
    string f,s;
    int fi,si;
    cin>>f>>s;
    if(f=="monday")fi=0;
    else if(f=="tuesday")fi=1;
    else if(f=="wednesday")fi=2;
    else if(f=="thursday")fi=3;
    else if(f=="friday")fi=4;
    else if(f=="saturday")fi=5;
    else fi=6;
    if(s=="monday")fi=0;
    else if(s=="tuesday")si=1;
    else if(s=="wednesday")si=2;
    else if(s=="thursday")si=3;
    else if(s=="friday")si=4;
    else if(s=="saturday")si=5;
    else si=6;
    if(fi>si)fi+=7;
int p=si-fi;
p=p%7;
if(p==0 || p==2 || p==3)cout<<"YES";
else cout<<"NO";
return 0;
}

#include<iostream>
using namespace std;
string week[8]={"monday","tuesday","wednesday","thursday","friday","saturday","sunday"};
string day1,day2;
int num1,num2;
main() {
       cin>>day1>>day2;

       for(int i=0;i<=6;i++) {
              if(week[i] == day1)
              num1 = i+1;
              if(week[i] == day2)
              num2 = i+1;
       }

       if(num1 - num2 >= 0) {
               if(num1 - num2 == 0 || num1 - num2 == 2 || num1 - num2 == 3)
               cout<<"YES"<<endl;
               else
               cout<<"NO"<<endl;

       }
       else
       if(num2 - num1 == 0 || num2 - num1 == 2 || num2 - num1 == 3)
       cout<<"YES"<<endl;
       else
       cout<<"NO"<<endl;

       //system("pause");
}

//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
using namespace std;
//作者：中国江苏南京朱泽齐
int a[13]={31,28,31,30,31,30,31,31,30,31,30,31};
int b[8],c[8];
string s1,s2;
int main(){
	cin>>s1;
	cin>>s2;
	if(s1=="monday")
	b[1]=1;
	if(s1=="tuesday")
	b[2]=2;
	if(s1=="wednesday")
	b[3]=3;
	if(s1=="thursday")
	b[4]=4;
	if(s1=="friday")
	b[5]=5;
	if(s1=="saturday")
	b[6]=6;
	if(s1=="sunday")
	b[7]=0;
	if(s2=="monday")
	c[1]=1;
	if(s2=="tuesday")
	c[2]=2;
	if(s2=="wednesday")
	c[3]=3;
	if(s2=="thursday")
	c[4]=4;
	if(s2=="friday")
	c[5]=5;
	if(s2=="saturday")
	c[6]=6;
	if(s2=="sunday")
	c[7]=0;
	for(int i=1;i<=12;i++)
	if((b[i]+a[i])%7==c[i]){
		cout<<"YES";
		return 0;
	}
	cout<<"NO";
	return 0;
}

                               /* THIS IS LATE NIGHT CODER. GLAD U R SEEING THIS BUT TRY FORM YOURSELF. HAPPY COADING*/
#include<bits/stdc++.h>
#define ll long long
#define val 1e5+10
#define sc(a)                scanf("%d",&a)
#define sc2(a,b)           scanf("%d%d",&a,&b)
#define sc3(a,b,c)         scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d)      scanf("%d%d%d%d",&a,&b,&c,&d)
#define fl(c,i,n)             for(i=c;i<n;i++)
#define out(x)               printf("%lld\n",x)
#define LB(a,x)              (lower_bound(aov(a),x)-a.begin())
#define UB(a,x)            (upper_bound(aov(a),x)-a.begin())
#define PI                    (2.0*acos(0.0))
using namespace std;
int main(){
string str1,str2;
int flag1,flag2;
cin>>str1>>str2;
if(str1=="monday")
    flag1=1;
if(str2=="monday")
    flag2=1;
if(str1=="tuesday")
    flag1=2;
if(str2=="tuesday")
    flag2=2;
    if(str1=="wednesday")
    flag1=3;
if(str2=="wednesday")
    flag2=3;
    if(str1=="thursday")
    flag1=4;
if(str2=="thursday")
    flag2=4;
    if(str1=="friday")
    flag1=5;
if(str2=="friday")
    flag2=5;
    if(str1=="saturday")
    flag1=6;
if(str2=="saturday")
    flag2=6;
    if(str1=="sunday")
    flag1=7;
if(str2=="sunday")
    flag2=7;
if(flag1==flag2){
cout<<"YES";
}
else if(((flag1+flag2)<5)&&(flag1+2==flag2 || flag1+3==flag2))
cout<<"YES";
else if(flag1=5 &&(flag2==7 || flag2==1))
   cout<<"YES";
   else if(flag1=6 &&(flag2==1 || flag2==2))
   cout<<"YES";
   else if(flag1=7 &&(flag2==2 || flag2==3))
   cout<<"YES";
    else
        cout<<"NO";
return 0;
}

#include <math.h>
#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <stdio.h>
#include <cctype>
#define inf 2000000000
using namespace std;
int main(){
map <string,int> mp;
mp["monday"]=1;
mp["tuesday"]=2;
mp["wednesday"]=3;
mp["thursday"]=4;
mp["friday"]=5;
mp["saturday"]=6;
mp["sunday"]=7;
string s1,s2;
cin>>s1>>s2;
if((mp[s1]+3)%7==mp[s2]||(mp[s1]+2)%7==mp[s2]||abs(mp[s1]-mp[s2])==0)printf("YES");
else printf("NO");
return 0;
}

//  from KTL
#include<bits/stdc++.h>
using namespace std;
int i,j,ans,a,m,n;
string s,ss;
int main ()
{
	cin >> s >> ss;
	if (s == "monday")
	m = 1;
	if (s == "tuesday")
	m = 2;
	if (s == "wednesday")
	m = 3;
	if (s == "thursday")
	m = 4;
	if (s == "friday")
	m = 5;
	if (s == "saturday")
	m = 6;
	if (s == "sunday")
	m = 7;
	if (ss == "monday")
	n = 1;
	if (ss == "tuesday")
	n = 2;
	if (ss == "wednesday")
	n = 3;
	if (ss == "thursday")
	n = 4;
	if (ss == "friday")
	n = 5;
	if (ss == "saturday")
	n = 6;
	if (ss == "sunday")
	n = 7;
	if (m == n || m - n == 4 || n - m == 2 || n - m == 3)
	{
		cout << "YES";
	}
	else
	cout << "NO";

}

#include <stdio.h>
#include <string.h>
const char* msg[] = { "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"  };
int main()
{
	char a[ 15 ], b[ 15 ];
	int ma, mb;
	while ( ~scanf( "%s\n%s", a, b ) )
	{
		ma = 0, mb = 0;
		//printf( "%s%s%s\n", a, b, msg[ 0 ] );
		for ( int i = 0; i < 7; i++ )
		{
			if ( strcmp( a, msg[ i ] ) == 0 )
				ma = i;
			if ( strcmp( b, msg[ i ] ) == 0 )
				mb = i;
		}
		int ans = ma - mb;
		printf( "%d%d%d\n", ma, mb, ans );
		if ( ans == 0 || ans == 4 || ans == -3 || ans == -2 || ans == 5 )
			printf( "YES\n" );
		else
			printf( "NO\n" );
	}
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s[7]={"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};
    string s1,s2;
    cin>>s1>>s2;
    int i=0;
    while(s[i]!=s1)
    {
        i++;
    }
    int j=0;
    while(s[j]!=s2)
    {
        j++;
    }
    if(j>=i)
    {
    if(j-i==3||j-i==0||j-i==2)
    {
        cout<<"YES";
        return 0;
    }
    else
    cout<<"NO";
    return 0;
    }
    else
    {
        if(s1=="saturday")
        {
            if(s2=="monday"||s2=="tuesday")
            {
                cout<<"YES";
                return 0;
            }
            else
            {
                cout<<"NO";
                return 0;
            }

        }
        else if(s1=="sunday")
        {
            if(s2=="tuesday"||s2=="wednesday")
            {
                cout<<"YES";
                return 0;
            }
            else
            {
                cout<<"NO";
                return 0;
            }

        }
        cout<<"NO";
    }
}

#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>

using namespace std;

int main() {

	vector<string>a;
	a.push_back("monday");
	a.push_back("tuesday");
	a.push_back("wednesday");
	a.push_back("thursday");
	a.push_back("friday");
	a.push_back("saturday");
	a.push_back("sunday");
	a.push_back("monday");
	a.push_back("tuesday");
	a.push_back("wednesday");
	a.push_back("thursday");
	a.push_back("friday");
	a.push_back("saturday");
	a.push_back("sunday");
	string x, y;
	cin >> x >> y;

	int b = 0, c = 0;
	for (int i = 0; i < a.size(); i++) {
		if (x == a[i]) {
			b = i; break;
		}

	}

	if (a[b]==y || a[b+3] == y || a[b+4] == y)cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;

}

#include<bits/stdc++.h>
using namespace std;
map <string,int> m;
int main()
{
	m["mondey"]=1;
	m["tuesday"]=2;
	m["wednesday"]=3;
	m["thursday"]=4;
	m["friday"]=5;
	m["saturday"]=6;
	m["sunday"]=7;//周一到周七字符串转数字
	string a,b;
	cin>>a>>b;//读入
	int x=m[a],y=m[b];//a,b对应的数值
	if((y+7-x)%7==0||(y+7-x)%7==2||(y+7-x)%7==3) cout<<"YES";//加7是为了防止负数
	else cout<<"NO";//判断
	return 0;
}

#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int ak[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int main(){
	string a_,b_;cin>>a_>>b_;
	int a,b;
	if(a_=="monday") a=1;
	if(a_=="tuesday") a=2;
	if(a_=="wednesday") a=3;
	if(a_=="thursday") a=4;
	if(a_=="friday") a=5;
	if(a_=="saturday") a=6;
	if(a_=="sunday") a=7;

	if(b_=="monday") b=1;
	if(b_=="tuesday") b=2;
	if(b_=="wednesday") b=3;
	if(b_=="thursday") b=4;
	if(b_=="friday") b=5;
	if(b_=="saturday") b=6;
	if(b_=="sunday") b=7;

	for(int i=1;i<=11;i++)
	{
		if((a+(ak[i]%7)%7)==b){
			cout<<"YES";
			return 0;
		}
	}
	cout<<"NO";
	return 0;
}

#include<cstdio>
#include<string.h>
char C[7][20] = { "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};
int num[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main()
{
	char A[20];
	char B[20];
	int judge=0;
	int first, second;
	scanf("%s", A);
	scanf("%s", B);
	for(int i=0; i<7; i++)
	{
		if(strcmp(A, C[i])==0)
			first = i+1;
		else if(strcmp(B, C[i])==0)
			second = i+1;
	}
	for(int i=0; i<11; i++)
	{
		if( (first + num[i]%7 )%7 == second%7 )
		{
			judge=1;
			break;
			}
	}
	if(judge == 1)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
 }

#define mm(a) memset(a,0,sizeof(a));
#define max(x,y) (x)>(y)?(x):(y)
#define min(x,y) (x)<(y)?(x):(y)
#define Fopen freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,b,a) for(int i=(b);i>=(a);i--)
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int INF=0x3f3f3f3f;
const int MAXN=405;//vertex
const int MAXM=1005;//edge
int n;
map<string,int>mp;
string a,b;
int main()
{
//    printf("%d\n",29%7);
    mp["monday"]=0;
    mp["tuesday"]=1;
    mp["wednesday"]=2;
    mp["thursday"]=3;
    mp["friday"]=4;
    mp["saturday"]=5;
    mp["sunday"]=6;
    cin>>a>>b;
    if((mp[a]+30)%7==mp[b]||(mp[a]+28)%7==mp[b])puts("YES");
    else puts("NO");
    return 0;
}

#include<string>
#include<algorithm>
#include<iostream>
#include<map>
#include<stdio.h>
#include<vector>
#include<set>
#include <cstring>
//#include<multiset>

using namespace std;

void processing(long long int x)
{
   if(x==0)
   {
      cout<<"YES"<<endl;
   }
   else if(x==2)
   {
      cout<<"YES"<<endl;
   }
   else if(x==3)
   {
      cout<<"YES"<<endl;
   }
   else
   {
      cout<<"NO"<<endl;
   }
}

int main(void)
 {
    map<string,long long int> myMap;
    for(long long int i=0;i<7;++i)
    {
      myMap["saturday"]=0;
      myMap["sunday"]=1;
      myMap["monday"]=2;
      myMap["tuesday"]=3;
      myMap["wednesday"]=4;
      myMap["thursday"]=5;
      myMap["friday"]=6;
   }
    long long int T;
    cin>>T;
    for(long long int h=0;h<T;++h)
    {
      string s1,s2;
      cin>>s1>>s2;
      long long int x=abs(myMap[s1]-myMap[s2]);
      processing( x);
    }
 }

#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

const string s[7]={"monday","tuesday","wednesday","thursday","friday","saturday","sunday"};
string s1,s2;
int l1,l2;

int main()
{
    cin>>s1>>s2;
    for (int i=0;i<7;i++)
    {
        if (s[i]==s1)
            l1=i+1;
        if (s[i]==s2)
            l2=i+1;
    }
    if (abs(l1-l2)!=1)
            cout<<"YES";
    else
            cout<<"NO";
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vi;
#define mp make_pair
#define pb push_back
#define fo(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<n;i++)
#define Fo(i,n) for(int i=1;i<=n;i++)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
int main()
{
    fast;
    string p[7]={"sunday","monday","tuesday","wednesday","thursday","friday","saturday"};
    string s,r;
    cin>>s>>r;
    ll temp;
    fo(i,7)
    if(s.compare(p[i])==0)
    {
        temp=i;
        break;
    }
    ll count=-1;
    for(int i=0;i<4;i++)
    {
        count++;
        if(r.compare(p[(i+temp)%7])==0){
           break;
        }
    }
    if(count==0||count==2||count==3)
    cout<<"YES";
    else
        cout<<"NO";
    return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
        char *ch[7]={"thursday","friday","saturday","sunday","monday","tuesday","wednesday"};
       int mant=12,date,c=-1,v=0,ckr,n=-1,m=-1,s=-1,result,last=0;
       char str1[10],str2[10];
       gets(str1);
       gets(str2);
       while(c<1352)
    {
       char ch2[12]={31,28,31,30,31,30,31,31,30,31,30,31};
        for(int i=0;i<mant;i++)
          {
            date=ch2[i];
          for(int k=1;k<=date;k++)
           {
               c++;
               v++;
                if(c%7==0){v=0;}
               if(k==1)
                {
                    m++;
                 ckr=strcmp(str1,ch[v]);
                 result=strcmp(str2,ch[v]);
                  if(result==0)
                   {
                       s=m;
                       int test=n+1;
                       if(s>0)
                       {
                           if(s==test){last=1;}
                       }
                   }
                  if(ckr==0)
                   {
                       n=m;
                   }
                }
           }
        }
    }
    if(last==1){cout<<"YES";}
    else
    {
        cout<<"NO";
    }
}

                               /* THIS IS LATE NIGHT CODER. GLAD U R SEEING THIS BUT TRY FORM YOURSELF. HAPPY COADING*/
#include<bits/stdc++.h>
#define ll long long
#define val 1e5+10
#define sc(a)                scanf("%d",&a)
#define sc2(a,b)           scanf("%d%d",&a,&b)
#define sc3(a,b,c)         scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d)      scanf("%d%d%d%d",&a,&b,&c,&d)
#define fl(c,i,n)             for(i=c;i<n;i++)
#define out(x)               printf("%lld\n",x)
#define LB(a,x)              (lower_bound(aov(a),x)-a.begin())
#define UB(a,x)            (upper_bound(aov(a),x)-a.begin())
#define PI                    (2.0*acos(0.0))
using namespace std;
int main(){
string str1,str2;
int flag1,flag2;
cin>>str1>>str2;
if(str1=="monday")
    flag1=1;
if(str2=="monday")
    flag2=1;
if(str1=="tuesday")
    flag1=2;
if(str2=="tuesday")
    flag2=2;
    if(str1=="wednesday")
    flag1=3;
if(str2=="wednesday")
    flag2=3;
    if(str1=="thursday")
    flag1=4;
if(str2=="thursday")
    flag2=4;
    if(str1=="friday")
    flag1=5;
if(str2=="friday")
    flag2=5;
    if(str1=="saturday")
    flag1=6;
if(str2=="saturday")
    flag2=6;
    if(str1=="sunday")
    flag1=7;
if(str2=="sunday")
    flag2=7;
if(flag1>=flag2)
    cout<<"YES";
    else
        cout<<"NO";
return 0;
}

#include <iostream>
using namespace std;
string s ,ss;
int a,a1;
int main()
{
	cin >> s;
	cin >> ss;
	if(s=="monday")
	{
		a=1;
	}
		if(s=="tuesday")
	{
		a=2;
	}
		if(s=="wednesday")
	{

		a=3;
	}
		if(s=="thursday")
	{
		a=4;
	}
		if(s=="friday")
	{
		a=5;
	}
		if(s=="saturday")
	{
		a=6;
	}
		if(s=="sunday")
	{
		a=7;
	}
		if(s=="monday")
	{
		a1=1;
	}
		if(ss=="tuesday")
	{
		a1=2;
	}
		if(ss=="wednesday")
	{

		a1=3;
	}
		if(ss=="thursday")
	{
		a1=4;
	}
		if(ss=="friday")
	{
		a1=5;
	}
		if(ss=="saturday")
	{
		a1=6;
	}
		if(ss=="sunday")
	{
		a1=7;
	}
	if(a==a1 || (a+2)%7==a1  || (a+3)%7==a1)
	{
		cout << "YES";
	}
	else
	cout << "NO";

}

#include <iostream>
using namespace std;

int findDay(string day){
	if(day == "monday")
	return 1;
	if(day == "tuesday")
	return 2;
	if(day == "wednesday")
	return 3;
	if(day == "thursday")
	return 4;
	if(day == "friday")
	return 5;
	if(day == "saturday")
	return 6;
	if(day == "sunday")
	return 7;

}
int main() {
	string day1, day2;
	cin>>day1>>day2;
	int a, b;

	a = findDay(day1);
	b = findDay(day2);

	int c = (a-b+7)%7;
	if(c == 0 || c == 2 || c == 3)
		cout<<"YES";
	else
		cout<<"NO";

	return 0;
}

#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<stdio.h>
#include<queue>
#include<iomanip>
#include<string>
#include<cstdio>
using namespace std;
int main(){
    string a;
    int Olog1,Ologn;
    cin>>a;
    if(a=="monday")Olog1=1;
    else if(a=="tuesday")Olog1=2;
    else if(a=="wednesday")Olog1=3;
    else if(a=="thursday")Olog1=4;
    else if(a=="friday")Olog1=5;
    else if(a=="saturday")Olog1=6;
    else if(a=="sunday")Olog1=7;
    cin>>a;
    if(a=="monday")Ologn=1;
    else if(a=="tuesday")Ologn=2;
    else if(a=="wednesday")Ologn=3;
    else if(a=="thursday")Ologn=4;
    else if(a=="friday")Ologn=5;
    else if(a=="saturday")Ologn=6;
    else if(a=="sunday")Ologn=7;
    //30天==+2天      31天==+3天      28天==啥都没干
    //cout<<Ologn<<" "<<Olog1;
    int whata=min(Olog1,Ologn),whatb=max(Olog1,Ologn);
    if(whatb-whata==1)cout<<"NO";
    else cout<<"YES";
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s1,s2;
	int flag=0;
	cin>>s1>>s2;
	if(s1==s2)
	{
	flag=1;
    }
    else if(s1=="monday")
    {
    	if(s2=="wednesday"||s2=="thrusday")
    	flag=1;
	}
	else if(s1=="tuesday")
    {
    	if(s2=="friday"||s2=="thrusday")
    	flag=1;
	}
	else if(s1=="wednesday")
    {
    	if(s2=="friday"||s2=="saturday")
    	flag=1;
	}
	else if(s1=="thrusday")
    {
    	if(s2=="saturday"||s2=="sunday")
    	flag=1;
	}
	else if(s1=="friday")
    {
    	if(s2=="sunday"||s2=="monday")
    	flag=1;
	}
	else if(s1=="saturday")
    {
    	if(s2=="monday"||s2=="tuesday")
    	flag=1;
	}
	else if(s1=="sunday")
    {
    	if(s2=="wednesday"||s2=="thrusday")
    	flag=1;
	}
	if(flag)
	cout<<"YES"<<endl;
	else
	cout<<"NO"<<endl;
}

#include <bits/stdc++.h>
#define ll long long
#define lli long long int
#define endl "\n"

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
        cin.tie(NULL);
    	//
    string day0,day1;
    string arr[30] = { "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"},arr2[30];

    cin >> day0 >> day1;

    int n1,n2;
    for(int i=0;i<7;i++)
     if(arr[i] == day0)
        n1 = i+1;
    for(int i=0;i<7;i++)
     if(arr[i] == day1)
        n2 = i+1;

    //if (n1 > n2)
      //  n2+=7;
    if(abs(n1 - n2) == 0|| abs(n1 - n2) == 5 || abs(n1 - n2) == 3 || abs(n1 - n2) == 4)
        cout << "YES";
    else
        cout << "NO";
    return(0);

	return (0);
}

#include<bits/stdc++.h>

using namespace std;
int main(){
int a,b,n;
string s1,s2;
cin>>s1;
cin>>s2;
vector<int> v;
map<string,int> v2;
v2.insert({"monday",1});
v2.insert({"tuesday",2});
v2.insert({"wednesday",3});
v2.insert({"thursday",4});
v2.insert({"friday",5});
v2.insert({"saturday",6});
v2.insert({"sunday",7});
//cout<<v2[s1]<<" "<<v2[s2];
a=v2[s1];
b=v2[s2];
//cout<<a<<" "<<b;
if(v2[s1]<=4){
if(abs(a-b)==0||abs(a-b)==2||abs(a-b)==3)
cout<<"YES";
    else
cout<<"NO";
}
else if(v2[s1]==5){
    if(abs(a-b)==0||a-b==-2||a-b==4)
cout<<"YES";
else
cout<<"NO";
}
else if(v2[s1]==6){
    if(abs(a-b)==0||abs(a-b)==5||abs(a-b)==4)
cout<<"YES";
else
cout<<"NO";
}
else if(v2[s1]==7){
    if(abs(a-b)==0||abs(a-b)==6||abs(a-b)==5)
cout<<"YES";
else
cout<<"NO";
}
else
cout<<"NO";
return 0;
}

#include <bits/stdc++.h>

#define Fori(x) for(int i=0;i<x;i++)
#define Forj(x) for(int j=0;j<x;j++)
#define maxn 5005
#define inf 0x3f3f3f3f
#define ONES(x) __builtin_popcount(x)
using namespace std;

typedef long long ll ;
const double eps =1e-8;
const int mod = 1000000007;
typedef pair<int, int> P;
const double PI = acos(-1.0);
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};

int n,m;
int ans;
string s1,s2;
map<string,int>mon;
 ///"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday".
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    //freopen("test.txt","r",stdin);
    cin>>s1>>s2;
    mon["monday"] = 0;
    mon["tuesday"] = 1;
    mon["wednesday"] = 2;
    mon["thursday"] = 3;
    mon["friday"] = 4;
    mon["saturday"] = 5;
    mon["sunday"] = 6;
    if(mon[s1]==3 && mon[s2]==0)
        cout << "YES" << endl;
    else if(mon[s1]==4 && mon[s2]==1)
        cout << "YES" << endl;
    else if(mon[s1]==5 && mon[s2]==2)
        cout << "YES" << endl;
    else if(mon[s1]==6 && mon[s2]==3)
        cout << "YES" << endl;
    else if(mon[s1]==4 && mon[s2]==0)
        cout << "YES" << endl;
    else if(mon[s1]==5 && mon[s2]==1)
        cout << "YES" << endl;
    else if(mon[s1]==6 && mon[s2]==2)
        cout << "YES" << endl;
    else if(mon[s2]-mon[s1]==0 || mon[s2]-mon[s1]==3 || mon[s2]-mon[s1]==4)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    //cout << ans << endl;
    return 0;
}

/*

unsigned   int   0～4294967295
int   2147483648～2147483647
unsigned long 0～4294967295
long   2147483648～2147483647
long long的最大值：9223372036854775807
long long的最小值：-9223372036854775808
unsigned long long的最大值：18446744073709551615

__int64的最大值：9223372036854775807
__int64的最小值：-9223372036854775808
unsigned __int64的最大值：18446744073709551615

*/

#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

const string s[7]={"monday","tuesday","wednesday","thursday","friday","saturday","sunday"};
string s1,s2;
int l1,l2;

int main()
{
    cin>>s1>>s2;
    for (int i=0;i<7;i++)
    {
        if (s[i]==s1)
            l1=i+1;
        if (s[i]==s2)
            l2=i+1;
    }
    if (l1>l2 && l1!=7 && l1!=6 && l1!=5)
    {
        cout<<"NO";
        return 0;
    }
    if (l2-l1!=1 && abs(l1-l2)!=6)
            cout<<"YES";
    else
            cout<<"NO";
    return 0;
}

//prepared by dumb
#include<bits/stdc++.h>
using namespace std;
#define        ll long long int
#define        dl double
#define        llu unsigned long long int
#define        scll(x) scanf("%lld",&x)
#define        scld(x) scanf("%lf",&x)
#define        scull(x) scanf("%llu",&x)
#define        scch(x) scanf(" %c",&x)
#define        pb(x) push_back(x)
#define        pf(x) push_front(x)
#define        ppb() pop_back()
#define        ppf() pop_front()
#define        Pi acos(-1.0)
#define        INF 1e18
#define        ff first
#define        ss second
#define        mpr make_pair
#define        debug(x) cout<<x<<'\n';
dl sin_deg(dl x){return sin((x*Pi)/180.0);}
dl cos_deg(dl x){return cos((x*Pi)/180.0);}
dl tan_deg(dl x){return tan((x*Pi)/180.0);}
dl asin_deg(dl x){return (asin(x)*180)/Pi;}
dl acos_deg(dl x){return (acos(x)*180)/Pi;}
dl atan_deg(dl x){return (atan(x)*180)/Pi;}
ll  _xor(ll a,ll b){return a^b;}
ll _and(ll a,ll b){return a&b;}
ll _or(ll a,ll b){return a|b;}
ll _not(ll a){ return ~a;}
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
           #ifndef ONLINE_JUDGE
         freopen("input.txt","r",stdin);
         freopen("output.txt","w",stdout);
         #endif
ll a,b,c,d,e,f=0,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;
ll cnt=0,ans=0,l1,l2,l3,c1=0,c2=0,c3=0,mx=0,mn=0,f1,f2,f3,v1,v2,v3,tst,t1,t2,t3,t4;
ll prevsum=0;
      string str1,str2;
        /*scll(t);
        while(t--)
        {
        scll(n);
        for()
        }*/
      cin>>str1;
      cin>>str2;
      map<string,ll>mp;
      mp["saturday"]=0;
      mp["sunday"]=1;
       mp["monday"]=2;
        mp["tuesday"]=3;
         mp["thrusday"]=4;
          mp["wednesday"]=5;
           mp["friday"]=6;

           if((mp[str1]+3)%7==mp[str2])cout<<"YES";
           else if((mp[str1]+2)%7==mp[str2])cout<<"YES";
           else if(mp[str1]==mp[str2])cout<<"YES";
           else
            cout<<"NO";
return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{

string a,b,c[10];
int f=0,g=0;
while(cin>>a>>b)
{

if((a=="monday"&&b=="tuesday")||(a=="tuesday"&&b=="wednesday")||(a=="wednesday"&&b=="thursday"))
    cout<<"NO"<<endl;
    else if((a=="thursday"&&b=="friday")||(a=="friday"&&b=="saturday")||(a=="saturday"&&b=="sunday"))
    cout<<"NO"<<endl;
    else if(a=="sunday"&&b=="monday")
cout<<"NO"<<endl;

else
    cout<<"YES"<<endl;

}
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

#define MOD 1000000007
const int MAX = 1e5 + 7;
const int INF = 1e9;
long long n, m, l, k, t, p, q, a, b, c, d, x, y, cnt = 0, ans = 0;
int month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string ar[] = {"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};
map<string, int>mp;
string s, tt;

bool check()
{
        for(int i = 0; i < 11; ++i)
        {
                if(mp[s] - mp[tt] == (month[i] % 7) + 1  ||  mp[tt] - mp[s] == (month[i] % 7) + 1)
                        return true;
        }
        return false;
}

int MAIN()
{
        for(int i = 0; i < 7; ++i)
                mp[ar[i]] = i;
        cin >> s >> tt;
        if(check()  ||  s == tt)
                cout << "YES";
        else
                cout << "NO";
        return 0;
}

int main()
{
        ios_base::sync_with_stdio(false);
        int start = clock();
        #ifndef ONLINE_JUDGE
                freopen("in.txt", "rt", stdin);
                //freopen("out.txt", "wt", stdout);
        #endif
        cout << fixed << setprecision(16);
        int ret = MAIN();
        #ifndef ONLINE_JUDGE
            cout << "[Finished in " << clock() - start << " ms]" << "\n";
        #endif
        return ret;
}

#include <cmath>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <map>
#include <vector>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  map<string, int> a;
  a["monday"] = 1;
  a["tuesday"] = 2;
  a["wednesday"] = 3;
  a["thursday"] = 4;
  a["friday"] = 5;
  a["saturday"] = 6;
  a["sunday"] = 7;
  string s1, s2;
  cin >> s1 >> s2;
  int a1 = (a[s1] - a[s2] + 28) % 7;
  if (a1 == 3 || a1 == 2 || a1 == 0 || a1 == 4 || a1 == 5) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
  return 0;
}

#include <iostream>
using namespace std;

int str(string str)
{
    if(str == "monday")
    {
        return 1;
    }
    if(str == "tuesday")
    {
        return 2;
    }
    if(str == "wednesday")
    {
        return 3;
    }
    if(str == "thursday")
    {
        return 4;
    }
    if(str == "friday")
    {
        return 5;
    }
    if(str == "saturday")
    {
        return 6;
    }
    if(str == "sunday")
    {
        return 7;
    }
}

int main()
{
    string str1, str2;
    cin >> str1 >> str2;
    int day1, day2;
    day1 = str(str1);
    day2 = str(str2);
    int ans = (day2 - day1) % 7;
    if(ans == 0 || ans == 2 || ans ==3)
    {
        cout << "YES" << endl;
    }
    else
        cout << "NO" << endl;
    return 0;
}

#include <bits/stdc++.h>
#include <limits.h>
#include <string.h>
#include <stdlib.h>
using namespace std;
typedef float fl;
typedef char ch;
typedef long long ll;
#define rep(i,a,n) for(i=a;i<n;i++)
#define rev(i,n,a) for(i=n;i>=a;i--)
#define repr(i,a,b) for(i=a;i<b;i++)
#define s(n) scanf("%d",&n);
#define s2(n,m) scanf("%d%d",&n,&m);
#define s3(n,m,o) scanf("%d%d%d",&n,&m,&o);
#define p(n) printf("%d ",n);
#define p2(n,m) printf("%d %d",n,m);
#define pl2(n,m) printf("%lld %lld",n,m);
#define sc(n) scanf("%c",&n);
#define sf(n) scanf("%f",&n);
#define sl(n) scanf("%lld",&n);
#define pc(n) printf("%c",n);
#define pf(n) printf("%f",n);
#define pl(n) printf("%lld",n);
#define br break;
#define co continue;
#define ss(a) scanf("%s",&a);
#define ps(a) printf("%s",a);
#define nl printf("\n");
#define r0 return 0;
int main()
{
    ch a[15],b[15];
    ss(a)
    ss(b)
    int y,z;
    if(a[0]=='m')
        y=1;
    else if(a[2]=='e')
        y=2;
    else if(a[0]=='w')
        y=3;
    else if(a[0]=='t')
        y=4;
    else if(a[0]=='f')
        y=5;
    else if(a[1]=='a')
        y=6;
    else
        y=7;
    if(b[0]=='m')
        z=1;
    else if(b[2]=='e')
        z=2;
    else if(b[0]=='w')
        z=3;
    else if(b[0]=='t')
        z=4;
    else if(b[0]=='f')
        z=5;
    else if(b[1]=='a')
        z=6;
    else
        z=7;
    if(z>=y)
        z-=y;
    else
        z=7+z-y;
    if(z==0||z==3||z==3)
        printf("YES");
    else
        printf("NO");
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

const string s[7]={"monday","tuesday","wednesday","thursday","friday","saturday","sunday"};
string s1,s2;
int l1,l2;

int main()
{
    cin>>s1>>s2;
    for (int i=0;i<7;i++)
    {
        if (s[i]==s1)
            l1=i+1;
        if (s[i]==s2)
            l2=i+1;
    }
    if (abs(l1-l2)!=1)
            cout<<"YES";
    else
            cout<<"NO";
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main(){
	string a , b , c , d  ;
	int x , y , z ,e ;
	cin>> a >> b ;
	if( a == "sunday" ){
		x = 2;
	}
	if( a == "monday"){
		x = 3 ;
	}
	if( a == "tuesday" ){
		x = 4 ;
	}
	if( a == "wednesday" ){
		x = 5 ;
	}
	if( a == "thursday" ){
		x = 6 ;
	}
	if( a == "friday" ){
		x = 7 ;
	}
	if( a == "saturday" ){
		x = 1 ;
	}
	if(b == "sunday" ){
		y = 2;
	}
	if( b == "monday"){
		y = 3 ;
	}
	if( b == "tuesday" ){
		y = 4 ;
	}
	if( b == "wednesday" ){
		y = 5 ;
	}
	if( b == "thursday" ){
		y = 6 ;
	}
	if( b == "friday" ){
		y = 7 ;
	}
	if( b == "saturday" ){
		y = 1 ;
	}
	e =  ( x - y ) ;
	if( e==0 || e== -3 || e==-2 ){
		cout<<"YES" ;
	}
	else {
		cout<<"NO" ;
	}

}

#include<stdio.h>
#include<iostream>
#include<cmath>
using namespace std;
int allot(string s)
{
  if(s=="monday") return 0;
  if(s=="tuesday") return 1;
  if(s=="wednesday") return 2;
  if(s=="thursday") return 3;
  if(s=="friday") return 4;
  if(s=="saturday") return 5;
  if(s=="sunday") return 6;
}
int main()
{
   string s1,s2;
   cin>>s1>>s2;
   int d1=allot(s1);
   int d2=allot(s2);
   if(min(abs(d1-d2),7-abs(d1-d2))==0||
      min(abs(d1-d2),7-abs(d1-d2))==3||
      min(abs(d1-d2),7-abs(d1-d2))==2)
        cout<<"YES";
   else   cout<<"NO";
   return 0;
}

#include <iostream>
#include <cmath>
#include <cstring>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <iomanip>
#include <cctype>
#include <stdlib.h>
#include <stdio.h>
#include <fstream>
#include <sstream>
#include <climits>

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define re return
#define in insert
#define all(x) x.begin(), x.end()
#define MOD 1000000007
#define MAXN 100007
#define f(i, n) for (int i = 0; i < n; i++)
#define F(i, a, b) for (int i = a; i <= b; i++)
#define len(x) x.size()
#define I "%d"
#define II "%d%d"
#define III "%d%d%d"

using namespace std;

typedef vector <int> :: iterator IntItVec;
typedef vector <string> :: iterator StrItVec;
typedef set <int> :: iterator IntItSet;
typedef set <string> :: iterator StrItSet;
typedef long long int ll;

int DetermineInput(string day) {
    if (day == "monday")
        return 1;
    if (day == "tuesday")
        return 2;
    if (day == "wednesday")
        return 3;
    if (day == "thursday")
        return 4;
    if (day == "friday")
        return 5;
    if (day == "saturday")
        return 6;
    if (day == "sunday")
        return 7;
}

int main()
{
    ios_base::sync_with_stdio(false);

    string fday1, fday2;
    cin >> fday1 >> fday2;

    int day1 = DetermineInput(fday1);
    int day2 = DetermineInput(fday2);

    int x = max(day1, day2) - min(day1, day2);

    if (x == 1)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;

    re 0;
}

#include<bits/stdc++.h>
using namespace std;

int main(){
	string a , b , c , d , e ;
	int x , y , z ;
	cin>> a >> b ;
	if( a == "sunday" ){
		x = 2;
	}
	if( a == "monday"){
		x = 3 ;
	}
	if( a == "tuesday" ){
		x = 4 ;
	}
	if( a == "wednesday" ){
		x = 5 ;
	}
	if( a == "thursday" ){
		x = 6 ;
	}
	if( a == "friday" ){
		x = 7 ;
	}
	if( a == "saturday" ){
		x = 1 ;
	}
	if(b == "sunday" ){
		y = 2;
	}
	if( b == "monday"){
		y = 3 ;
	}
	if( b == "tuesday" ){
		y = 4 ;
	}
	if( b == "wednesday" ){
		y = 5 ;
	}
	if( b == "thursday" ){
		y = 6 ;
	}
	if( b == "friday" ){
		y = 7 ;
	}
	if( b == "saturday" ){
		y = 1 ;
	}
	if(abs(x - y) >= 3 || abs(x -y) == 1){
		cout<<"NO" ;
	}
	else if(abs(x - y) >= 3 && abs ( x - y) != 1){
		cout<<"YES" ;
	}
}

#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;
map<string,int> ma;
void init()
{
   string  ans[7]={ "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};
   for (int i=0;i<7;i++)
   {
       ma[ans[i]]=i;
   }
}
int main()
{
    init();
    string str1,str2;
    cin>>str1>>str2;
    int d1=ma[str1];
    int d2=ma[str2];
    if ((d2-d1+7)==0||(d2-d1+7)==3||(d2-d1+7)==2) cout<<"YES\n";
    else cout<<"NO\n";
    return 0;
}

#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int ak[]={0,2,3};
int main(){
	string a_,b_;cin>>a_>>b_;
	int a,b;
	if(a_=="monday") a=1;
	if(a_=="tuesday") a=2;
	if(a_=="wednesday") a=3;
	if(a_=="thursday") a=4;
	if(a_=="friday") a=5;
	if(a_=="saturday") a=6;
	if(a_=="sunday") a=7;

	if(b_=="monday") b=1;
	if(b_=="tuesday") b=2;
	if(b_=="wednesday") b=3;
	if(b_=="thursday") b=4;
	if(b_=="friday") b=5;
	if(b_=="saturday") b=6;
	if(b_=="sunday") b=7;

	for(int i=0;i<=2;i++)
	{
		if((a+(ak[i]%7)%7)==b){
			cout<<"YES";
			return 0;
		}
	}
	cout<<"NO";
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,h;
    int a,b;
    cin>>s>>h;
    if(s=="saturday")
        a=1;
    else if(s=="sunday")
        a=2;
    else if(s== "monday")
        a=3;
    else if(s== "tuesday")
        a=4;
    else if(s== "wednesday")
        a=5;
    else if(s=="thursday")
        a=6;
    else if(s=="friday")
        a=7;
    if(h== "saturday")
        b=1;
    else if(h=="sunday")
        b=2;
    else if(h== "monday")
        b=3;
    else if(h== "tuesday")
        b=4;
    else if(h== "wednesday")
        b=5;
    else if(h=="thursday")
        b=6;
    else if(h=="friday")
        b=7;

    if(b-a==0 || b-a==2 || b-a==3 || (b==1 && a==5) || (b==2 && a==6) || (b==3 && a==7))
    {
        cout<<"YES";
    }
    else
        cout<<"NO";

}

#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s,c;
    int a,b;
    cin >> s >> c;
    if (s=="monday")
    {
        a=0;
    }
    if (s=="tuesday")
    {
        a=1;
    }
      if (s=="wednesday")
    {
        a=2;
    }
      if (s=="thursday")
    {
        a=3;
    }
      if (s=="friday")
    {
        a=4;
    }
      if (s=="saturday")
    {
        a=5;
    }
      if (s=="sunday")
    {
        a=6;
    }
    if (c=="monday")
    {
       b=0;
    }
    if (c=="tuesday")
    {
        b=1;
    }
      if (c=="wednesday")
    {
        b=2;
    }
      if (c=="thursday")
    {
        b=3;
    }
      if (c=="friday")
    {
        b=4;
    }
      if (c=="saturday")
    {
        b=5;
    }
      if (c=="sunday")
    {
        b=6;
    }
    if(a == b || (a+3)%7 == b || (a+3)%7 == b)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }

    return 0;
}

#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
using namespace std;
string a;
string b;
int x[10];
int f[20]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int n;
int up;
void ss(string s)
{
	if(s=="monday")
	{x[up]=1;}
	if(s=="tuesday")
	{
		x[up]=2;
	}
	if(s=="sunday")
	{
		x[up]=0;
	}
	if(s=="wednesdy")
	{
		x[up]=3;
	}
	if(s=="tuesday")
	{
	   x[up]=2;
	}
	if(s=="friday")
	{
		x[up]=5;
	}
	if(s=="saturday")
	{
		x[up]=6;
	}
	if(s=="thursday")
	{
		x[up]=4;
	}
}
int main()
{

	n=7;
	cin>>a;
	cin>>b;up++;
	ss(a);up++;ss(b);
	bool ok=0;
	int sum[20];
	if((x[1]+2)%7==x[2]) cout<<"YES";
	else 	if(x[2]==x[1])cout<<"YES";
	else if((x[1]+3)%7==x[2])cout<<"YES";
	else cout<<"NO";
	return 0;

}

#include<bits/stdc++.h>
using namespace std ;
int main()
{
    int n,p;
    string s,s1 ;
    cin>>s>>s1;
    if(s=="saturday") n=1;
    else if(s=="sunday") n=2;
    else if(s=="monday") n=3;
    else if(s=="tuesday") n=4;
    else if(s=="wedday") n=5;
    else if(s=="thursday") n=6;
    else if(s=="friday") n=7;
    if(s1=="saturday") p=1;
    else if(s1=="sunday") p=2;
    else if(s1=="monday") p=3;
    else if(s1=="tuesday") p=4;
    else if(s1=="wedday") p=5;
    else if(s1=="thursday") p=6;
    else if(s1=="friday") p=7;

    int w=n-p;
    if(w == 2 || w==0 || w==4 || w== -2 || w==3|| w== -3 ) printf("YES");
    else printf("NO");
}

#include <iostream>
#include <cstdio>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <iterator>

#define ll long long
#define ld long double

#define y1 abc

#define endl '\n'

#define fi first
#define se second

#define pb push_back
#define pob pop_back

using namespace std;

ll a1, a2;

string s1, s2;

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> s1;

    cin >> s2;

    if (s1 == "monday") a1 = 1;
    else if (s1 == "tuesday") a1 = 2;
    else if (s1 == "wednesday") a1 = 3;
    else if (s1 == "thursday") a1 = 4;
    else if (s1 == "friday") a1 = 5;
    else if (s1 == "saturday") a1 = 6;
    else a1 = 7;

    if (s2 == "monday") a2 = 1;
    else if (s2 == "tuesday") a2 = 2;
    else if (s2 == "wednesday") a2 = 3;
    else if (s2 == "thursday") a2 = 4;
    else if (s2 == "friday") a2 = 5;
    else if (s2 == "saturday") a2 = 6;
    else a2 = 7;

    if (a1 - a2 > 3) a2 += 7;

    if (a1 - a2 == 0 || a1 - a2 == 2 || a1 - a2 == 3) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

                               /* THIS IS LATE NIGHT CODER. GLAD U R SEEING THIS BUT TRY FORM YOURSELF. HAPPY COADING*/
#include<bits/stdc++.h>
#define ll long long
#define val 1e5+10
#define sc(a)                scanf("%d",&a)
#define sc2(a,b)           scanf("%d%d",&a,&b)
#define sc3(a,b,c)         scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d)      scanf("%d%d%d%d",&a,&b,&c,&d)
#define fl(c,i,n)             for(i=c;i<n;i++)
#define out(x)               printf("%lld\n",x)
#define LB(a,x)              (lower_bound(aov(a),x)-a.begin())
#define UB(a,x)            (upper_bound(aov(a),x)-a.begin())
#define PI                    (2.0*acos(0.0))
using namespace std;
int main(){
string str1,str2;
int flag1,flag2;
cin>>str1>>str2;
if(str1=="monday")
    flag1=1;
if(str2=="monday")
    flag2=1;
if(str1=="tuesday")
    flag1=2;
if(str2=="tuesday")
    flag2=2;
    if(str1=="wednesday")
    flag1=3;
if(str2=="wednesday")
    flag2=3;
    if(str1=="thursday")
    flag1=4;
if(str2=="thursday")
    flag2=4;
    if(str1=="friday")
    flag1=5;
if(str2=="friday")
    flag2=5;
    if(str1=="saturday")
    flag1=6;
if(str2=="saturday")
    flag2=6;
    if(str1=="sunday")
    flag1=7;
if(str2=="sunday")
    flag2=7;
if(abs(flag1-flag2)==2 || abs(flag1-flag2)==0 || abs(flag1-flag2)==3)
    cout<<"YES";
    else
        cout<<"NO";
return 0;
}

#include <iostream>
#include <cmath>
#include <string>
using namespace std;
int main(){

    string s1,s2;
    cin>>s1>>s2;
    int v1,v2;

if(s1=="sunday"){
    v1=0;
    }

  else  if(s1=="monday"){
    v1=1;
    }
   else   if(s1=="tuesday"){
    v1=2;
    }

     else if(s1=="wednesday"){
    v1=3;
    }

    else  if(s1=="thursday"){
    v1=4;
    }
     else if(s1=="friday"){
    v1=5;
    }
    else if(s1=="saturday"){
    v1=6;
    }

if(s2=="sunday"){
    v2=0;
    }

  else  if(s2=="monday"){
    v2=1;
    }
   else   if(s2=="tuesday"){
    v2=2;
    }

     else if(s2=="wednesday"){
    v2=3;
    }

    else  if(s2=="thursday"){
    v2=4;
    }
     else if(s2=="friday"){
    v2=5;
    }
    else if(s2=="saturday"){
    v2=6;
    }

    if(v2<v1){
    v2+=6;
    }
    int check = v2-v1;
    if(check>=-2 && check < 0 ){
     cout<<"NO";
    }
    else if((check == 0 || check == 2 || check == 3)  ){
    cout<<"YES";
    }
    else{
    cout<<"NO";
    }

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int check(string s)
{
    if(s=="sunday")
        return 1;
    else if(s=="monday")
        return 2;
    else if(s=="tuesday")
        return 3;
    else if(s=="wednesday")
        return 4;
    else if(s=="thursday")
        return 5;
    else if(s=="friday")
        return 6;
    return 7;
}
int main()
{
   string s,t;
   cin>>s>>t;
   int a=check(s),b=check(t);
   if(min(abs(b-a),7-abs(b-a))==3||min(abs(b-a),7-abs(b-a))==2||b-a==0)
    cout<<"YES"<<endl;
   else cout<<"NO"<<endl;
}

#include<bits/stdc++.h>
#define up(j,k,i) for(i=j;i<k;i++)
#define down(j,k,i) for(i=j;i>k;i--)
#define pp(n) printf("%lld\n",n)
#define is(n) scanf("%lld",&n)
#define ips(n) scanf("%lld",n)
#define ss(s) scanf("%s",s)
#define cool 0
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define f(i) cout<<i<<endl;
#define pll pair<lld,lld>
#define pi acos(-1)
#define ds(n,m) scanf("%lld %lld",&n,&m)
#define ts(n,m,k) scanf("%lld %lld %lld",&n,&m,&k)
typedef long double ld;
typedef long long int lld;
using namespace std;
const lld M =1e18+7;
const lld mod=1e9+7;
const lld infi =1e18+7;
lld a[]={ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
map <string ,lld> cnt;
int main()
{
cnt[ "monday"]=1;
cnt["tuesday"]=2;
cnt["wednesday"]=3;
 cnt["thursday"]=4;
 cnt["friday"]=5;
 cnt[ "saturday"]=6;
 cnt ["sunday"]=7;
        lld i,j,ans=0;
        string a,b;
        cin>>a>>b;
        lld na=cnt[a],nb=cnt[b];
        na=na-nb;
        na+=7;
        na=na%7;
        up(0,11,i)
        {
          ans=a[i]-1;
          if(ans%7==(na))
          {
            cout<<"YES\n";
            return 0;
          }
        }
        cout<<"NO\n"
;        return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str1,str2;
    int dif;
    map<string,int>mp;
    mp["saturday"]=7;
    mp["sunday"]=6;
    mp["monday"]=5;
    mp["tuesday"]=4;
    mp["wednesday"]=3;
    mp["thursday"]=2;
    mp["friday"]=1;
    cin>>str1>>str2;
    if(mp[str1]<mp[str2])
        mp[str1]+=7;
    dif=(mp[str1]-mp[str2]);
    if(dif==3||dif==0)
    {
        cout<<"YES"<<endl;return 0;
    }
    cout<<"NO"<<endl;
    return 0;
}

#define mm(a) memset(a,0,sizeof(a));
#define max(x,y) (x)>(y)?(x):(y)
#define min(x,y) (x)<(y)?(x):(y)
#define Fopen freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,b,a) for(int i=(b);i>=(a);i--)
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int INF=0x3f3f3f3f;
const int MAXN=405;//vertex
const int MAXM=1005;//edge
int n;
map<string,int>mp;
string a,b;
int main()
{
//    printf("%d\n",29%7);
    mp["monday"]=0;
    mp["tuesday"]=1;
    mp["wednesday"]=2;
    mp["thursday"]=3;
    mp["friday"]=4;
    mp["saturday"]=5;
    mp["sunday"]=6;
    cin>>a>>b;
    if((mp[a]+30)%7==mp[b]||(mp[a]+28)%7==mp[b])puts("YES");
    else puts("NO");
    return 0;
}

#include <iostream>
using namespace std;
string b,c,a[7]={"monday","tuesday","wendesday","thursday","friday","satureday","sanday"};
int k,g;
main()
{
cin>>b>>c;
cout<<"yes"<<endl;
for(int i=0;i<7;i++)
{ if(a[i]==c) k=i;
if(a[i]==b) g=i;
}
if( (g-k+3)%7==0 || (g-k)%7==0 || (g-k+2)%7==0)
cout<<"yes"<<endl;
else cout<<"no"<<endl;

}

#include<iostream>
#include<cstring>
#include<cstdio>

using namespace std;

int main()
{
    string a[8],x,y;
    int b,c,i;
    a[1]="monday";
    a[2]="tuesday";
    a[3]="wednesday";
    a[4]="thursday";
    a[5]="friday";
    a[6]="saturday";
    a[7]="sunday";

    cin>>x>>y;

    for(i=1;i<8;i++)
    {
        if(a[i]==x){
         b=i;
         break;
        }
    }
    if(a[b]==y)
    {
        cout<<"YES"<<endl;
    }
    else if(a[b+2]==y)
        cout<<"YES"<<endl;
    else if(a[b+3]==y)
        cout<<"YES"<<endl;

    else{
        cout<<"NO"<<endl;
    }

}

#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int ak[10][10];
int ad[]={2,3,0,0};
int main(){
	string a_,b_;cin>>a_>>b_;
	int a,b;
	if(a_=="monday") a=1;
	if(a_=="tuesday") a=2;
	if(a_=="wednesday") a=3;
	if(a_=="thursday") a=4;
	if(a_=="friday") a=5;
	if(a_=="saturday") a=6;
	if(a_=="sunday") a=7;

	if(b_=="monday") b=1;
	if(b_=="tuesday") b=2;
	if(b_=="wednesday") b=3;
	if(b_=="thursday") b=4;
	if(b_=="friday") b=5;
	if(b_=="saturday") b=6;
	if(b_=="sunday") b=7;

	for(int i=0;i<=2;i++)
	{
		if(((a+ad[i])%7)==b){
			cout<<"YES";
			return 0;
		}
	}
	cout<<"NO";
	return 0;
}

#include <cstdio>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int months[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

string days[] = {"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};

int strday(string str){
	for(int i=0;i<7;i++){
		if(days[i]==str)
			return i;
	}
}

int main(){
//	freopen("input.txt","r",stdin);
	string day1,day2;
	int d1,d2;
	cin >> day1;
	cin >> day2;
	d1 = strday(day1);
	d2 = strday(day2);

	for(int i=0;i<11;i++){
//		cout << (months[i]-d1)%7+1 << endl;
		//cout << months[i] << " " << d1 << " " << (months[i]+d1)%7 << " " << d2 << endl;
		if((months[i]+d1-1)%7+1==d2){
			cout << "YES";
			return 0;
		}
	}
	cout << "NO";
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main () {

	string a,b;
	cin>>a>>b;
	int i;
	int j;
	string n[7]={"monday","tuesday","wednesday","thursday","friday","saturday","sunday"};
	int m[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	for(int w=0;w<7;w++){
		if(n[w]==a){
			i=w;
		}
	}
	for(int l=0;l<7;l++){
		if(n[l]==b){
			j=l;
		}
	}
	if(abs(i-j)==0 or abs(i-j)==2 or abs(i-j)==3){
		cout<<"YES";
		return 0;
	}
	cout<<"NO";
return 0 ;
}

#include<bits/stdc++.h>
using namespace std;
int get(string p)
{
    if(p=="monday")
     return 1;
     if(p=="tuesday")
    return 2;
    if(p=="wednesday")
        return 3;
    if(p=="thurday") return 4;
    if(p=="friday") return 5;
    if(p=="saturday") return 6;
    if(p=="sunday") return 7;
}
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    int a,b;
    a=get(s1),b=get(s2);
    if(abs(a-b)%7==1||abs(a-b)%7==3)
        cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
}

/*******************************\
 Name: MD ASHRAFUZZAMAN KHAN |
 School: COMILLA UNIVERSITY |
 CSE (5TH BATCH) |
 ********************************/

#include <bits/stdc++.h>

#define ll long long int
#define inf 1<<30
#define Pi 2*acos(0,0)
#define pi acos(-1)
#define PI 3.1415926535897932384626433832795
#define mem(x,y) memset(x,y,sizeof(x))
#define pf printf
#define sf scanf
#define MAX 50

template < class T > inline T gcd(T a,T b) {a=abs(a);b=abs(b); if(!b) return a; return __gcd(b,a%b);}
template < class T > inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/__gcd(a,b))*b;}
//template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T ncr(T n,T r){return n*(n-1)/r;}

using namespace std;

int main()
{
    string str;
    string cur="a";
    cin>>str;
    int count=0;
    int len=str.length();
    for(int i=0;i<len;i++)
    {
        if(abs(str[i]-cur[0])>13)
           {
               count+=26-(abs(str[i]-cur[0]));

           }
        else{
            count+=(abs(str[i]-cur[0]));
        }
        cur[0]=str[i];

    }
    cout<<count<<endl;
  return 0;
}

#include<stdio.h>
#include<iostream>
using namespace std;
int allot(string s)
{
  if(s=="monday")  return 0;
  if(s=="tuesday")  return 1;
  if(s=="wednesday")  return 2;
  if(s=="thursday")  return 3;
  if(s=="friday")  return 4;
  if(s=="saturday")  return 5;
  if(s=="sunday")  return 6;
}
int main()
{
   string s1,s2;
   cin>>s1>>s2;
   int d1=allot(s1);
   int d2=allot(s2);
   if(d2>=d1)
   {
      if(d2-d1==3||d2-d1==2||d2-d1==0)
        cout<<"YES";
      else   cout<<"NO";
   }
   else
   {
      if(6-d1+d2==3||6-d1+d2==0||6-d1+d2==2)
        cout<<"YES";
      else   cout<<"NO";
   }
   return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int ,int > P;
const int maxn = 2e5 + 20;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const ll inf = 3e18;
vector<int >res;
map<string ,int > dp;
string str[12] ={"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};
int A[13] = {0,31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} ,sum[13];
int main(void){
    dp["monday"] = 1,dp["tuesday"] = 2,dp["wednesday"] = 3,dp["thursday"] = 4,dp["friday"] = 5,dp["saturday"] = 6,dp["sunday"] = 6;
    string s1,s2;
    cin>>s1>>s2;
    int a = dp[s1],b = dp[s2],d = 0;
    d = 7  - a + b;
    if(d >= 7) d-=7;
  A[0] = 0;
    for(int i = 1; i <= 12; i ++) sum[i] = sum[i - 1] + A[i];
    for(int i = 1; i <= 12; i ++){
            if(A[i] %7 == d || A[i] %7 == d){
             //   flag = true;
                cout<<"YES"<<endl;
                return 0;
            }

    }
    cout<<"NO"<<endl;
    return 0;
}

#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>

using namespace std;

int main() {

	vector<string>a;
	a.push_back("monday");
	a.push_back("tuesday");
	a.push_back("wednesday");
	a.push_back("thursday");
	a.push_back("friday");
	a.push_back("saturday");
	a.push_back("sunday");
	a.push_back("monday");
	a.push_back("tuesday");
	a.push_back("wednesday");
	a.push_back("thursday");
	a.push_back("friday");
	a.push_back("saturday");
	a.push_back("sunday");
	string x, y;
	cin >> x >> y;

	int b = 0, c = 0;
	for (int i = 0; i < a.size(); i++) {
		if (x == a[i])b = i;

	}

	if (a[b]==y || a[b+3] == y || a[b+4] == y)cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;

}

#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
map<string,int> a;
int main(){
	string b,c;
	a["monday"]=0;
	a["tuesday"]=1;
	a["wednesday"]=2;
	a["thursday"]=3;
	a["friday"]=4;
	a["saturday"]=5;
	a["sunday"]=6;
	cin>>b>>c;
	int x=a[c]-a[b];
	if((x==4||x==5)||(x==0||(x==2||x==3)))
		cout<<"YES";
	else
		cout<<"NO";
}

//  from KTL
#include<bits/stdc++.h>
using namespace std;
int i,j,ans,a,m,n;
string s,ss;
int main ()
{
	cin >> s >> ss;
	if (s == "monday")
	m = 1;
	if (s == "tuesday")
	m = 2;
	if (s == "wednesday")
	m = 3;
	if (s == "thursday")
	m = 4;
	if (s == "friday")
	m = 5;
	if (s == "saturday")
	m = 6;
	if (s == "sunday")
	m = 7;
	if (ss == "monday")
	n = 1;
	if (ss == "tuesday")
	n = 2;
	if (ss == "wednesday")
	n = 3;
	if (ss == "thursday")
	n = 4;
	if (ss == "friday")
	n = 5;
	if (ss == "saturday")
	n = 6;
	if (ss == "sunday")
	n = 7;
	if (m == n || n - m == 2  )
	{
		cout << "YES";
	}
	else
	cout << "NO";

}

//http://codeforces.com/contest/724/problem/A

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iterator>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <list>

using namespace std;

#define endl "\n"
#define pii pair <int, int>
#define pll pair <long long, long long>
#define vi vector <int>
#define ll long long
#define mp make_pair
#define fir first
#define sec second

string fir, sec;
int month[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
string result = "NO";
map <string, int> monthNumber;

int main()
{
	int ii;
	int num1, num2;

	ios::sync_with_stdio(false);

	cin >> fir >> sec;

	monthNumber["monday"] = 0;
	monthNumber["tuesday"] = 1;
	monthNumber["wednesday"] = 2;
	monthNumber["thursday"] = 3;
	monthNumber["friday"] = 4;
	monthNumber["satursday"] = 5;
	monthNumber["sunday"] = 6;

	num1 = monthNumber[fir];
	num2 = monthNumber[sec];

	for (ii = 0; ii < 12; ii++)
	{
		if (((num1 + month[ii]) % 7) == num2)
		{
			result = "YES";

			break;
		}
	}

	cout << result << endl;

	return 0;
}

#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;

char a[15];
char b[15];

char table[7][15] = {"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};

int main()
{
    int c,d,i,j;
    scanf("%s %s",a,b);

    for(i=0;i<7;i++) {
        bool flag=true;
        if(strlen(a) == strlen(table[i])) {
            for(j=0;j<strlen(table[i]);j++) {
                if(table[i][j] != a[j])
                    break;
            }
        }
        else flag = false;

        if(flag) c=i+1;
    }

    for(i=0;i<7;i++) {
        bool flag=true;
        if(strlen(b) == strlen(table[i])) {
            for(j=0;j<strlen(table[i]);j++) {
                if(table[i][j] != b[j])
                    break;
            }
        }
        else flag = false;

        if(flag) d=i+1;
    }

    if(c>d) d+=6;

    if(d-c == 0 || d-c == 2 || d-c == 3)
        puts("YES");
    else puts("NO");
    return 0;
}

#include <iostream>
#include <string>
#include <map>
#include <bits/stdc++.h>
using namespace std;

int main()
{
map <string,int>m;
m["monday"]=1;
m["tuesday"]=2;m["wednesday"]=3;m["thursday"]=4;m["friday"]=5;m["saturday"]=6;m["sunday"]=7;
string s,a;
cin>>s>>a;
if(s==a||abs(m[s]-m[a])==4||abs(m[s]-m[a])==3)cout<<"YES\n";
else cout<<"NO\n";

    return 0;
}

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <stack>
#include <algorithm>
#include <string>
#include <set>
#include <math.h>
#include <queue>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long l;
typedef pair<ll, ll> p;
typedef vector<ll> v;

#define F(I,J) for(ll i = I; i < J; i++)

int main()
{
	map<string, int> A = { { "sunday", 0 }, { "monday", 1 }, { "tuesday", 2 }, { "wednesday", 3 }, { "thursday", 4 }, { "friday", 5 }, { "saturday", 6 } };
	string a, b;
	cin >> a >> b;
	if ((A[a] - A[b]) % 7 == 2 || (A[a] - A[b]) % 7 == 0 || (A[a] - A[b]) % 7 == 2) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
	return 0;
}

#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define MOD 1000000007

using namespace std;
typedef long long ll;
const int MAX = 1e6 + 10;
const int MIN = 5e3 + 10;
const int MAXI = INT_MAX;
const int MINI = -INT_MAX;
const ll MAXL = (1e17 + 10);
const ll MINL = -(1e17 + 10);

ll arr[MAX], n;
string s1, s2;
map <string, int> m;

int main ()
{
	m["monday"] = 2;
	m["tuesday"] = 3;
	m["wednesday"] = 4;
	m["thursday"] = 5;
	m["friday"] = 6;
	m["saturday"] = 7;
	m["sunday"] = 1;
	cin >> s1 >> s2;
	int i = m[s1];
	int j = m[s2];
	int x = (i + j) % 7;
	if (x == 2 || x == 3 || s1 == s2 || x == 3)
		cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

#include <iostream>
#include <string.h>
using namespace std;

int main()
{
	int x, i,j,k;
	char days[7][12] = { "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday" };
	char s1[12], s2[12];
	cin >> s1;
	cin >> s2;
	for (i = 0; i<7; i++)
	{
		//cout << days[i] << endl;
		if (strcmp(s1,days[i])==0)
		{
			if (i>3)
			{
				j = i + 2 - 7;
				k = i + 3 - 7;
			}
			if (strcmp(s2,days[i])==0 || strcmp(s2,days[j])==0|| strcmp(s2,days[k])==0)
			{
				cout << "YES";
			}
			else
			{
				cout << "NO";
			}
		}
	}
	//cout << "notfound";
	//system("pause");
	return 0;
}

#include <bits/stdc++.h>

#define sz(s) s.size()
#define sr(s) sort(s.begin(), s.end())
#define rs(s) reverse(s.begin(), s.end())
#define ar(a, n) sort(a + 1, a + n + 1)
#define ra(a, n) reverse(a + 1, a + n + 1)
#define solved exit(0);
#define S second
#define F first

typedef long long ll;

using namespace std;

const int N = 1e5 + 15;
const int LL = 1e9 + 15;
const int SSS = 1e6 + 15;

string s, t, dd[10] = {"", "monday", "tuesday", "wednsday", "thursday", "friday", "saturday", "sunday"};

int i1, i2, ans, d[50], days[15] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

map < string, int> mp;

main()
{

	cin >> s >> t;
	for (int i = 1; i <= 7; ++i)
		mp[dd[i]] = i;
	for (int i = 1; i <= 7; ++i)
	{
		if (s == dd[i])
			i1 = i;
		if (t == dd[i])
			i2 = i;
	}
	for (int i = 1; i <= 12; ++i)
	{
		ans = i1 + (days[i] % 7);
		if (ans > 7)
			ans %= 7;
		if (ans == i2)
		{
			cout << "YES";
			return 0;
		}
	}
	cout << "NO";
    return 0;
}

                               /* THIS IS LATE NIGHT CODER. GLAD U R SEEING THIS BUT TRY FORM YOURSELF. HAPPY COADING*/
#include<bits/stdc++.h>
#define ll long long
#define val 1e5+10
#define sc(a)                scanf("%d",&a)
#define sc2(a,b)           scanf("%d%d",&a,&b)
#define sc3(a,b,c)         scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d)      scanf("%d%d%d%d",&a,&b,&c,&d)
#define fl(c,i,n)             for(i=c;i<n;i++)
#define out(x)               printf("%lld\n",x)
#define LB(a,x)              (lower_bound(aov(a),x)-a.begin())
#define UB(a,x)            (upper_bound(aov(a),x)-a.begin())
#define PI                    (2.0*acos(0.0))
using namespace std;
int main(){
string str1,str2;
int flag1,flag2;
cin>>str1>>str2;
if(str1=="monday")
    flag1=1;
if(str2=="monday")
    flag2=1;
if(str1=="tuesday")
    flag1=2;
if(str2=="tuesday")
    flag2=2;
    if(str1=="wednesday")
    flag1=3;
if(str2=="wednesday")
    flag2=3;
    if(str1=="thursday")
    flag1=4;
if(str2=="thursday")
    flag2=4;
    if(str1=="friday")
    flag1=5;
if(str2=="friday")
    flag2=5;
    if(str1=="saturday")
    flag1=6;
if(str2=="saturday")
    flag2=6;
    if(str1=="sunday")
    flag1=7;
if(str2=="sunday")
    flag2=7;
int mid=(flag1-flag2);
if(mid==2 || mid==0|| mid==4)
    cout<<"YES";
    else
        cout<<"NO";
return 0;
}

#include<bits/stdc++.h>
using namespace std;
map<string,int>mp;
int main(){
    mp["monday"]=0;mp["tuesday"]=1;mp["wednesday"]=2;mp["thursday"]=3;mp["friday"]=4;
    mp["saturday"]=5;mp["sunday"]=6;
    string a,b;
    cin>>a>>b;
    int sum=(mp[b]-mp[a]);
    if(sum<0) sum+=7;
    //cout<<sum<<endl;
    if(sum%4==1 || sum%4==0) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
}

#include<bits/stdc++.h>

using namespace std;

map<string,int> m;

int main()
{
    ios::sync_with_stdio(false);

    m["monday"] = 1;
    m["tuesday"] = 2;
    m["wednesday"] = 3;
    m["thursday"] = 4;
    m["friday"] = 5;
    m["saturday"] = 6;
    m["sunday"] = 7;

    string a,b;
    int s;

    cin >> a >> b;

    s = m[b] - m[a];

    if(s == 0 || s == 2 || s == 3)
    {
        cout << "YES" << endl;

        return 0;
    }
    else
    {
        cout << "NO" << endl;

        return 0;
    }
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    map<string,int>p;
    p[ "saturday"] = 1;
    p["sunday"] = 2;
    p["monday"] = 3;
    p["tuesday"] = 4;
    p["wednesday"] = 5;
    p["thursday"] = 6;
    p["friday"] = 7;
    string s,str;
    cin>>s>>str;
    int k = p[s];
    int t = p[str];
    if(t-k==0||abs(t+k-7)==2||abs(t+k-7)==3)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}

#include<iostream>
#include<string>
#include<cmath>
#include<cctype>
#include<vector>
#include<sstream>
#include<algorithm>
#include<set>
#define pb push_back
using namespace std;
int main(){
	string s,c;
	cin>>s>>c;
	string a[7];
	a[0]="monday";
	a[1]="tuesday";
	a[2]="wednesday";
	a[3]="thursday";
	a[4]="friday";
	a[5]="saturday";
	a[6]="sunday";
	int s1,c1;
	for(int i=0;i<7;i++){
		if(a[i]==s){
			s1=i+1;
		}
		if(a[i]==c){
			c1=i+1;
		}
	}
	int u=0;
	if(s1>c1){
		if(c1-s1==3){
			u++;
		}
	}
	else{
		if(s1-c1==4){
			u++;
		}
	}
	if(s1-c1==0){
		u++;
	}
	if(c1-s1==2){
		u++;
	}
	if(s1==6&&c1==1){
		u++;
	}
	if(s1==7&&c1==2){
		u++;
	}
	if(u==0){
		cout<<"NO";
	}
	else{
		cout<<"YES";
	}

	return 0;
}

#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<climits>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;

map<string,int> m;
int main()
{
	int i,j,n,x,y;
	string s;
	m["monday"]=1;
	m["tuesday"]=2;
	m["wednesday"]=3;
	m["thursday"]=4;
	m["friday"]=5;
	m["saturday"]=6;
	m["sunday"]=7;
	int a[12]={1,4,4,7,2,5,7,3,6,1,4,6};
	cin>>s;
	x=m[s];
	cin>>s;
	y=m[s];
	for(i=0;i<11;i++)
	{
		if(abs(a[i]-a[i+1])==((y+7-x)%7+1))
		{
			cout<<"YES\n";
			return 0;
		}
	}
	cout<<"NO\n";
	return 0;
}