#include <bits/stdc++.h>

using namespace std;

#define MAX 505
#define ll long long
#define pb push_back
#define mk make_pair
#define sc second
#define fr first
#define pii pair < int, int >

const int N = (int)1e5 + 5;
const int INF = (int)1e9 + 7;

map <int, int> mp;

int b, ans;

void bfs (int a) {
        queue < pair < int, int > > q;
        q.push(mk(a, 0));
        mp[a] = 1;
        while (!q.empty()) {
                pair < int, int > v = q.front();
                q.pop();
                int x, x1;
                x = v.first + 1;
                x1 = -v.first;
                if (x == b || x1 == b) {
                        ans = v.sc + 1;
                        return ;
                }
                if (!mp[x]) {
                        q.push(mk(x, v.sc + 1));
                }
                if (!mp[x1]) {
                        q.push(mk(x1, v.sc + 1));
                }
        }
}


int main () {
        int a;scanf ("%d %d", &a, &b);
        bfs(a);
        printf ("%d", ans);
}
