#include using namespace std; #include using namespace atcoder; using ll=long long; using Graph=vector>; #define INF 1000000000 #define MOD 998244353 #define MAX 1000 int main(){ int X,Y; cin>>X>>Y; int r=X%4; int a=X/4; int b=Y/4; cout<<(3-a-b)*4+r<<'\n'; }