#include<iostream>
#include<unordered_set>
#include<vector>
#include<map>
using namespace std;
int main()
{
    char x,y;
    cin>>x>>y;
    if(x == y)
        cout<<x<<"\n";
    else if((x == '0' && y == '1') || (x == '1' && y == '0'))
        cout<<"2\n";
    else if((x == '0' && y == '2') || (x == '2' && y == '0'))
        cout<<"1\n";
    else 
        cout<<"0\n";
    return 0;
}
/*

*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<bool> vbl;
typedef vector<vector<bool>> vvbl;

void INX(){}
template<typename Head, typename... Tail>
void INX(Head&& head, Tail&&... tail)
{
    cin >> head;
    INX(forward<Tail>(tail)...);
}
void OUTX(){}
template<typename Head, typename... Tail>
void OUTX(Head&& head, Tail&&... tail)
{
    cout << head << endl;
    OUTX(forward<Tail>(tail)...);
}
void OUTX2(){cout << endl;}
template<typename Head, typename... Tail>
void OUTX2(Head&& head, Tail&&... tail)
{
    cout << head << ' ';
    OUTX2(forward<Tail>(tail)...);
}

#define ADD emplace_back
#define MP make_pair
#define __LONG_LONG_MIN__ (-__LONG_LONG_MAX__ - 1)

//#define MOD 1000000007 // 10^9 + 7
//setprecision(10)

int main()
{
    ll M, H;
    INX(M, H);
    OUTX((H % M == 0 ? "Yes" : "No"));


    return 0;
}
