#include<bits/stdc++.h>
using namespace std;
#define  mem(a,x) memset(a,x,sizeof(a));
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
#define  B   begin()
#define  E   end()
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;
int32_t main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>n>>m;
    vector<int>v;
    for(i=0;i<n;i++)
    {
        cin>>l;
        if(l!=m) v.pb(l);
    }
    for(int x:v) cout<<x<<" ";
    return 0;
}


#include <bits/stdc++.h>
#include <unordered_set>
#include <algorithm>
 
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repll(i,n) for (ll i = 0; i < (ll)(n); i++)
#define fore(x,a) for(auto&(x) : (a))
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
#define ALL(a) (a).begin(), (a).end()
 
const ll INFL = 1e18;
const int INFI = 1e9;
const int MOD = 1e9 + 7;
 
int main(){
  int x,y;
  cin >> x >> y;
  if(x == 0 && y == 0) {
    cout << 0 << endl;
  }
  if(x == 0 && y == 1) {
    cout << 2 << endl;
  }
  if(x == 0 && y == 2) {
    cout << 1 << endl;
  }
  if(x == 1 && y == 0) {
    cout << 2 << endl;
  }
  if(x == 1 && y == 1) {
    cout << 1 << endl;
  }
  if(x == 1 && y == 2) {
    cout << 0 << endl;
  }
  if(x == 2 && y == 0) {
    cout << 1 << endl;
  }
  if(x == 2 && y == 1) {
    cout << 0 << endl;
  }
  if(x == 2 && y == 2) {
    cout << 2 << endl;
  }
}