#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e3 + 10;
struct node {
int x,y;
};
int x,y,step;
int dx[] = {2,-2,2,-2,2,-2,2,-2,1,1,-1,-1},dy[] = {1,-1,-1,1,2,2,-2,-2,1,-1,1,-1};
bool pos[MAXN][MAXN];
void bfs() {
queue<node> que;
cin >> x >> y;
node k;
k.x = x,k.y = y;
que.push(k);
while(que.size()) {
k = que.front();
que.pop();
for(int i = 0;i < 12;i++) {
int fx = k.x + dx[i],fy = k.y + dy[i];
if(fx == 1 && fy == 1) {
cout << ++step << endl;
return ;
}
if(fx > 0 && fy > 0 && fx <= 20 && fy <= 20 && pos[fx][fy] == 0) {
pos[fx][fy] = 1;
node v;
v.x = fx,v.y = fy;
que.push(v);
}
}
step ++;
}
}
int main() {
for(int i = 1;i <= 2;i++) {
step = 0;
memset(pos,0,sizeof pos);
bfs();
}
return 0;
}