#include<bits/stdc++.h>
using namespace std;
#define en      '\n'
#define endl    '\n'
#define ll      long long int
#define pb      push_back
#define append  push_back
#define all(v)  (v).begin(),(v).end()
#define FOR(i,a,b,k) for(int i=a; k>0?i<b:i>b; i+=k)
#define fori(a) for(int i=0; i<a; i++)
#define forj(a) for(int j=0; j<a; j++)
#define fork(a) for(int k=0; k<a; k++)
#define MOD     1000000007
#define MAX     1000005
#define mset(a,s,k) memset(a,k,s*sizeof(a[0]))
#define ff first
#define ss second
#define __ <<" "<<
 
ll pow_(ll a,ll e,ll m=MOD){ll r=1;while(e){if(e&1)r=r*a%m;a=a*a%m;e>>=1;}return r;} 
int inv(ll a) {return pow_(a,MOD-2,MOD);}int add(ll a, ll b){return (a+b+MOD)%MOD;} int mul(ll a, ll b)
{return (MOD+a*b%MOD)%MOD;}int di(ll a, ll b){return mul(a,inv(b));}ll  ceil(ll a,ll b){return a/b+(a%b!=0);}
void print(vector<int>a){fori(a.size())cout<<a[i]<<" ";cout<<en;}void print(ll a,ll b,char k='\n'){cout<<a<<" "<<b<<k;}
void print(vector<int> *a,int n){fori(n)print(a[i]);}void print(int *a,int n){fori(n)cout<<a[i]<<" "; cout<<en;}
 
#define vi vector<int>
#define tp pair<ll,ll>

int arr[MAX]; ll N,K;
ll get(ll x){
    // cout<<x<<en;
    if(x>N) return 2*N-x+1;
    return x-1;
}
// 4-> 5+3 4+4 3+5
int solve(){
    cin>>N>>K;
    ll R=0;
    fori(2*N+1){
        if(i==0) continue;
        ll X=K+i;
        if(X<=0 || X>2*N) continue;
        R+=get(X)*get(i);
    }
    cout<<R;
    return 0;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1; 
    // cin>>t;
    while(t--){
        solve();
        // cout<<solve()<<en;
        // cout<<(solve()?"Yes":"No")<<endl;
    }
    return 0;
}
 
#include <bits/stdc++.h>
using namespace std;
int main (){
int a, b;
cin >> a >> b;
int a2=a/100+a%100/10+a%10;
int b2=b/100+b%100/10+b%10;
    if(a2>=b2){
        cout << a2;
    }
    else{
        cout << b2;
    }
return 0;
}