#include <iostream>
#include <iterator>
#include <string>
#include <algorithm>
#define MAX 32768
using namespace std;

string s1,s2;
string fun(int x)
{
    string s="";
    while(x!=0)
    {
        char c = '0'+x%2;
        s = s+c;
        x /= 2;
    }
    
    while(s.size()<16)
    {
        s.append("0");
    }
    reverse(s.begin(),s.end());
    return s;
}

int main() {
    int a, b;
    while (cin >> a >> b) { // 注意 while 处理多个 case
        int flag=0;
       s1 = fun(a);
       s1.append(s1);
       s2 = fun(b);
//       cout<<s1<<endl;
       for(int i=0;i<16;i++)
       {
            string sub = s1.substr(i,16);
            if(sub == s2)
            {
                flag=1;
                break;
            }
       }
        if(flag)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;

    }
}
// 64 位输出请用 printf("%lld")