#include <bits/stdc++.h>
using namespace std;
#define int long long int
const double pi = 3.14159265358979;
const int inf = 1e13;
const int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, 1, -1};
#define pii pair<int,int>
#define endl "\n"
#define dtor(deg) (((deg)/360)*2*pi)
#define all(a) a.begin(),a.end()
#define overload(_1,_2,_3,_4,name,...) name
#define _rep1(n) for(int i = 0; i < (n); i++)
#define _rep2(i,n) for(int i = 0; i < (n); i++)
#define _rep3(i,a,b) for(int i = (a); i < (b); i++)
#define _rep4(i,a,b,c) for(int i = (a); i < (b); i += (c))
#define rep(...) overload(__VA_ARGS__,_rep4,_rep3,_rep2,_rep1)(__VA_ARGS__)
#define _rrep1(n) for(int i = (n) - 1; i >= 0; i--)
#define _rrep2(i,n) for(int i = (n) - 1; i >= 0; i--)
#define _rrep3(i,a,b) for(int i = (b) - 1; i >= (a); i--)
#define rrep(...) overload(__VA_ARGS__,_null,_rrep3,_rrep2,_rrep1)(__VA_ARGS__)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define vv(type,name,size,...) vector<vector<type>> name(size,vector<type>(__VA_ARGS__))
#define ForEach(a,b) for_each(a.begin(),a.end(),b)
struct Edge { int to, cost; Edge(int to, int cost) : to(to), cost(cost) {} };
using Graph = vector<vector<Edge>>;
template <class T> bool chmin(T& a, T b){ if(a > b){ a = b; return 1; } return 0; }
template <class T> bool chmax(T& a, T b){ if(a < b){ a = b; return 1; } return 0; }

void Main(){
    int b, c, ans;
    cin >> b >> c;
    if(b == 0){
        cout << c << endl;
    }else if(b > 0 && c >= b * 2){
        ans = b * 2 + 1 + (c - 2);
        cout << ans << endl;        
    }else if(b < 0 && c >= abs(b) * 2 + 1){
        ans = abs(b) * 2 + c;
        cout << ans << endl;
    }else if(b > 0 && c == 3){
        cout << 5 << endl;
    }else if(b > 0 && c == 2){
        cout << 3 << endl;
    }else if(b > 0 && c == 1){
        cout << 2 << endl;
    }else if(b > 0){
        cout << 5 + (c - 3) * 2 << endl;
    }else if(b < 0 && c == 3){
        cout << 5 << endl;
    }else if(b < 0 && c == 2){
        cout << 3 << endl;
    }else if(b < 0 && c == 1){
        cout << 2 << endl;
    }else if(b < 0){
        cout << 5 + (c - 3) * 2 << endl;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(10) << fixed;
    Main();
}
#include <bits/stdc++.h>

int nextInt() {
    int temp; scanf("%d", &temp);
    return temp;
}
long long nextLL() {
    long long temp; scanf("%lld", &temp);
    return temp;
}

void print(int x, char endc = '\n') {
    printf("%d%c", x, endc);
    return;
}
void print(long long x, char endc = '\n') {
    printf("%lld%c", x, endc);
    return;
}
void print(size_t x, char endc = '\n') {
    printf("%zu%c", x, endc);
    return;
}
void print(float x, char endc = '\n') {
    printf("%f%c", x, endc);
    return;
}
void print(double x, char endc = '\n') {
    printf("%lf%c", x, endc);
    return;
}

template<typename T1, typename T2>
void print(std::pair<T1, T2> &p, char sepc = ' ', char endc = '\n') {
    print(p.first, sepc);
    print(p.second, endc);
    return;
}

template<typename T>
void print(std::vector<T> &v, char sepc = ' ', char endc = '\n') {
    for(T e : v) print(e, sepc);
    printf("%c", endc);
    return;
}

template<typename T>
void print(const std::set<T> &v, char sepc = ' ', char endc = '\n') {
    for(T e : v) print(e, sepc);
    printf("%c", endc);
    return;
}







using namespace std;



void eachTC() {
    long long B = nextLL(), C = nextLL();
    long long res;

    if(B == 0)
        res = C;
    else if(C == 1) {
        res = 2;
    }
    else if((B > 0 && B <= C/2) || (B < 0 && -B <= (C-1)/2)) {
        long long B1, B2;
        if(B > 0 && B <= C/2) {
            B1 = -B - (C-1)/2;
            B2 = B + (C-2)/2;
        }
        else {
            B1 = B - C/2;
            B2 = -B + (C-1)/2;
        }
        res = B2 - B1 + 1;
    }
    else res = 2*C - 1; // 2 * (C/2 + (C-1)/2)

    print(res);
}

int main() {
    int T = 1;
    while(T--) eachTC();

    return 0;
}