#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll b,c,ans;

ll solve1(ll b,ll c){
    ll depth=c/2,flip=c&1;
    if(depth<b)return (1+depth)*2-(!flip);
    else return b*2+1;
}

ll solve2(ll b,ll c){
    ll depth=c/2,flip=c&1;
    return max(ll(0),depth*2-(!flip));
}

int main(){
    scanf("%lld%lld",&b,&c);
    if(b>0)ans=solve1(b,c)+solve2(-b,c-1);
    else if(b==0)ans=1+solve2(b,c);
    else ans=solve2(b,c)+solve1(-b,c-1);
    printf("%lld",ans);
    return 0;
}
//wtrl,everybody hangbeat me
#include<bits/stdc++.h>
/*#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>*/
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef pair<ll,ll> pll;
/*=====================================================================*/
#define pb push_back
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define sz(a) (int)(a.size())
#define all(s) (s).begin(),(s).end()
#define m_p make_pair
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define forn(i,p,n) for(int i=p;i<=n;i++)
#define ford(i,p,n) for(int i=n;i>=p;i--)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();++i)
#define INF 1e9
#define PI acos(-1)
/*=====================================================================*/
string int_to_string(ll n)
{
	string s="";
	while(n)
	{
		ll now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
ll string_to_int(string s)
{
	ll n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
/*======================================================================*/
ll lcm(int a,int b)
{
	return a/__gcd(a,b)*b;
}
bool prime(int n)
{
	if(n==0||n==1)
	  return false;
	for(int i=2;i*i<=n;i++)
	  if(n%i==0)
	    return false;
	return true;
}
/*======================================================================*/
const int dx[]={-1,0,1,0};
const int dy[]={0,-1,0,1};
const int month[2][12]={{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31,30,31,30,31}};
/*======================================================================*/
int main()
{
    std::ios::sync_with_stdio(false);
  /*
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
  */
  /*====================================================================*/
  ll b,c;
  cin>>b>>c;
  if(c==1)
  {
  	if(b!=0)
  	{
  	  cout<<2<<endl;
    }
    else
    {
    	cout<<1<<endl; 
	}
  	return 0;
  }
  if(b>=0)
  { 
  ll ans=2;
  ans+=(c-1)/2+c/2-1;
  if((c-1)/2+c/2<max(2*abs(b)-1,(ll)0))
  {
    ans+=(c-1)/2+c/2;	
  } 
  else
  {
  	ans+=max(2*abs(b)-1,(ll)0);
  }
  cout<<ans<<endl;
  }
  else
  {
  ll ans=2;
  ans+=c/2+(c-1)/2;
  if((c-1)/2+c/2-1<max(2*abs(b)-1,(ll)0))
  {
    ans+=(c-1)/2+c/2-1;	
  } 
  else
  {
  	ans+=max(2*abs(b)-1,(ll)0);
  }
  cout<<ans<<endl;
  }
  return 0;
}


