#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb emplace_back 
#define mp make_pair
#define fi first 
#define se second 
#define all(v) v.begin(),v.end()
#define run ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0);
#define mod 1000000007
#define decimal(n,k) cout<<fixed<<setprecision(k)<<n<<endl 
#define LL_MAX LLONG_MAX 
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
int exp(int x,int y){int res=1;x=x%mod;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int modinv(int x){return exp(x,mod-2);}
int add(int a,int b){a%=mod,b%=mod;a=((a+b)%mod+mod)%mod;return a;}
int sub(int a,int b){a%=mod,b%=mod;a=((a-b)%mod+mod)%mod;return a;}
int mul(int a,int b){a%=mod,b%=mod;a=((a*b)%mod+mod)%mod;return a;}
int gcd(int a, int b){if (b == 0)return a; return gcd(b, a % b);}
int log2n( int n){ return (n > 1) ? 1 + log2n(n / 2) : 0;} 
int fac[100009];int ncr_mod(int n,int k){int ans=fac[n];ans*=modinv(fac[k]);ans%=mod;ans*=modinv(fac[n-k]);ans%=mod;return ans;}
vector<int>v_prime;void Sieve(int n){bool prime[n + 1];memset(prime,true,sizeof(prime));for (int p = 2; p*p <=n;p++){if(prime[p] ==true) {for(int i = p*p; i<= n; i += p)prime[i]=false;}}for(int p = 2;p<= n;p++)if (prime[p])v_prime.pb(p);}
vector<int>v_factor;void factor(int n){ for (int i=1; i<=sqrt(n); i++) {if (n%i == 0) {if (n/i == i) v_factor.pb(i);else { v_factor.pb(i),v_factor.pb(n/i);};} } sort(all(v_factor)); } 
void out(vector<int>&a){for(int i=0;i<a.size();i++) cout<<a[i]<<" ";  cout<<endl;} 
void sout(set<int>s){for(auto it=s.begin();it!=s.end();++it)cout<<*it<<" ";  cout<<endl;}  
void mout(map<int,int>mm){for(auto it=mm.begin();it!=mm.end();++it) cout<<it->fi<<" "<<it->se<<endl;}
int power(int x, int y){int temp;if( y == 0)return 1; temp = power(x, y / 2);if (y % 2 == 0) return temp * temp;else return x * temp * temp;}
 
 
// s.top().second;
 
 
signed main()
{
 
 
      run;
 
 
/* 
open for mod factorial
 
     fac[0]=1;
      for(int i=1;i<100009;i++)
      {
          fac[i]=fac[i-1]*i; 
           fac[i]%=mod;  
      }
*/
 
 
/*
  for sieve open this and use v_prime 
 
          int pp=pow(10,6)+100000;
               Sieve(pp);
*/
 
 
 //   factor(n)  &&   USE v_factor For calculating factors 
 
 
int  t=1;
//cin>>t;
while(t--)
{
             //  map<int,int>mp; // x.second-->frequency
 
 
             int  n,i,x,y,ok=0,sum=0,ans=0,j,k,cnt=0,m,c=0;
             int  h[100009]={0};
 
 
                 // cin>>n;
 
 
                 string s;
                cin>>s;
 
 n=s.size();

 for(i=n-1;i>=0;i--)
 {
     if(s[i]!='0')
     {
         c=i;
         break;
     }
     
 }
 string ss,ss1;

 for(i=0;i<=c;i++)
 {
     ss+=s[i];

 }
 ss1=ss;

 reverse(all(ss));
 if(ss1==ss)
 {
     yes;

 }
 else
 no;
 
 
}
}
#include <math.h>
#include <assert.h>

#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& v) {
    return is >> v.first >> v.second;
}

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& v) {
    for (T& i: v) {
        is >> i;
    }
    return is;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& v) {
    return os << v.first << " " << v.second;
}

template <typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
    int n = (int) v.size();
    for (int i = 0; i < n; ++i) {
        os << v[i] << (i == n - 1 ? "" : " ");
    }
    return os;
}

template <typename X>
void in(X& x) {
    std::cin >> x;
}

template <typename X, typename Y>
void in(X& x, Y& y) {
    in(x); in(y);
}

template <typename X, typename Y, typename Z>
void in(X& x, Y& y, Z& z) {
    in(x); in(y, z);
}

template <typename X, typename Y, typename Z, typename W>
void in(X& x, Y& y, Z& z, W& w) {
    in(x); in(y, z, w);
}

template <typename T>
void out(const T H) {
    std::cout << (H);
}

template <typename T1, typename... T2>
void out(const T1 H, const T2... T) {
    std::cout << (H) << " "; out(T...);
}

template <typename T>
void eout(const char *s, const T H) {
    std::cerr << s << "=" << H << "\n";
}

template <typename T1, typename... T2>
void eout(const char *s, const T1 H, const T2... T) {
    while (*s != ',') std::cerr << *s++;
    std::cerr << "=" << H << " | "; eout(++s, T...);
}

#define nl                std::cout << "\n"

#ifdef LOCAL
#define err(args...)      eout(#args, args)
#else
#define err(args...)      42
#endif

#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define per(i, n)         for (int i = (n) - 1; i > -1; --i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)

#define sz(v)             ((int) v.size())
#define all(v)            (v).begin(), (v).end()
#define lla(v)            (v).rbegin(), (v).rend()

#define no                std::cout << "NO\n"
#define yes               std::cout << "YES\n"

const int INF           = 2147483647;
const long long int LNF = 9223372036854775807LL;

using ll  = long long int;
using vl  = std::vector<ll>;
using vi  = std::vector<int>;
using vb  = std::vector<bool>;
using ii  = std::pair<int, int>;
using iii = std::pair< ii, int>;
using vii = std::vector<ii>;

const int N  = 505050;
const int MD = 1000*1000*1000 + 7;

int solve();
int main() {
    std::ios_base::sync_with_stdio(0); std::cin.tie(0);

    //int t; in(t); repr(tc, 1, t + 1)
    solve();

    return 0;
}

int solve() {
    int n, k; in(n, k);
    ll ans = 0;
    for (int t = std::max(2, 2 + k); t <= std::min(2*n, 2*n + k); ++t) {
        int na = std::min(t - 1, n) - std::max(t - n, 1) + 1;
        int u = t - k;
        int nc = std::min(u - 1, n) - std::max(u - n, 1) + 1;
        ans += (ll) na*nc;
    }
    out(ans);
    return 0;
}
