include<iostream>
using namespace std;
int main(){
int m,d;
cin>>m,d;
cout<<(m*2+d)%3<<endl;
return 0
}