#include <bits/stdc++.h>
#include <queue>
using namespace std;
struct node {
	long long step;
	long long now;
}tmp;
queue<node> q;
long long x, y;
long long ans;
void bfs() {
	tmp.step = 0, tmp.now = x;
	q.push(tmp);
	while (!q.empty()) {
		node u = q.front();
		q.pop();
		if (u.now == y) {
			ans = u.step;
			return ;
		}
		node t;
		t.step = u.step + 1;
		t.now = u.now + 1;
		q.push(t);
		t.now = u.now * -1;
		q.push(t);
	}
}
int main() {
	scanf ("%lld %lld", &x, &y);
	bfs();
	printf ("%lld", ans);
	return 0;
}