#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << '\n'; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll bb, cc;
    cin, bb, cc;
    if (bb == 0) {
        print(cc / 2 * 2 + (cc % 2));
        return 0;
    }
    ll ans = 0;
    {
        ll b = bb;
        ll c = cc;
        if (b < 0) {
            c--;
            b = -b;
        }
        ll m = b - c / 2;
        if (m <= 0) {
            ans += 2 * b + 1;
            dump(ans);
        } else {
            ans += 2 * (b - m + 1);
            if ((c % 2) == 0) {
                ans--;
            }
            dump(ans);
        }
    }
    {
        ll b = bb;
        ll c = cc;
        if (bb > 0) {
            c--;
        } else {
            b = -b;
        }
        ans += c / 2 * 2;
        dump(ans);
        if (c / 2 > 0 && (c % 2) == 0) {
            ans--;
            dump(ans);
        }
    }
    print(ans);

    return 0;
}

#include<bits/stdc++.h>
//#include <atcoder/all>

#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define fi first
#define se second
#define sz(x) ((int)x.size())
 
using namespace std;
//using namespace atcoder;
using ld = long double;
using ll = long long;
using P = pair<ll, ll>;
 
template<typename T> bool chmin(T& a, const T& b) { if(a > b){ a = b; return 1;} return 0; }
template<typename T> bool chmax(T& a, const T& b) { if(a < b){ a = b; return 1;} return 0; }

const ll ZER = 0;
const ll MOD = 998244353;
const ll INF = 1e18;


int main(){
    ll b, c;
    cin >> b >> c;
    ll res;
    if(b > 0)res = 2 * min(c, 2 * b) - 1 + max((ll)0, c - 2 * b);
    if(b == 0)res = c;
    if(b < 0){
        b *= -1;
        res = 2 * min(c, 2 * b + 1) - 1 + max((ll)0, c - 2 * b - 1);
    }
    if(c == 1){
        res = 2 - (int)(!b);
    }
    cout << res << endl;
}