#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll mod=1e9+7;
#define rep(i,n) for (int i = 0; i < (n); i++)
ll b,c,ans;
int main(){
    cin >> b >> c;
    ll k=c/2;
    if(c==1){
        if(b==0)ans=1;
        else ans=2;
    }
    else if(c%2==1) ans=(k*4+1)-max(0LL,min(b+k-1,k-b)-max(-b-k,b-k)+1);
    else ans=(k*4-1)-max(0LL,min(b+k-1,k-b-1)-max(-b-k+1,b-k)+1);
    cout << ans << endl;
    return 0;
    

}

#include <bits/stdc++.h>
using namespace std;

int main() {

  int64_t B,C;
  cin >> B >> C;

  int64_t ans = 0;

  if(B == 0){
    cout << C << endl;
    return 0;
  }

  if(C < 3){
    cout << C+1 << endl;
    return 0;
  }

  if(abs(B) >= C){
    cout << (C-2)*2+3 << endl;
    return 0;
  }else{
    if(C <= abs(B)*2){
      cout << (C-2)*2+3 << endl;

      return 0;
    }

    if(B <= 0){
      cout << C + -B*2 << endl;
    }else{
      cout << C + B*2 - 1 << endl;
    }

  }








}