#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <fstream>
#include <algorithm>
#include <stack>
#include <deque>
#include <iomanip>
#include <queue>
#include <sstream>


using namespace std;


#define int long long
#define ull unsigned long long

int mod = 998244353;


int fact(int n){
    int f = 1;
    for(int i = 1; i < n; i++){
        f = (f * (i + 1)) % mod;
    }
    return f;
}

void HeapSort(vector<int>& values) {
    make_heap(values.begin(), values.end());
    for (auto i = values.end(); i != values.begin(); --i) {
        pop_heap(values.begin(), i);
    }
}

int bp(int a, int m){
    if(m == 1)return a;
    if(m % 2) return (a *bp(a, m - 1));
    int t = bp(a, m / 2);
    return (t * t);
}

vector<int> er(int n, vector<int> &g){
    vector<int> val;
    int v = n;
    while(v != 1){
        if(val.empty() || val[val.size() - 1] != g[v]){
            val.push_back(g[v]);
        }
        v = v / g[v];
    }
    return val;
}


struct edg{
    int v, u, w;
};


signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m; cin >> n >> m;
    vector <int> one(n);
    vector <int> two(n);
    one[0] = 1;
    two[0] = 4;
    for(int i = 1; i < n; i++)
    {
        one[i] = one[i - 1] + i + 2;
    }
    if(m > 1)
    {
        two[1] = 12;
        for(int i = 2; i < n;i++)
        {
            two[i] = (two[i - 1] - two[i - 2]) + two[i - 1] + 2;
        }
        vector<int> ans(max(n, m));
        ans[0] = one[n - 1];
        ans[1] = two[n - 1];
        for(int i = 2; i < m;i++)
        {
            ans[i] = (ans[i - 1] - ans[i - 2]) + m + ans[i - 1];
        }
        cout << ans[m - 1];
    }
    else
    {
        vector<int> ans(m);
        if(m == 1)
        {
            cout << one[0];
        }
        else if(m == 2)
        {
            cout << two[0];
        }
        else
        {
            ans[0] = one[m - 1];
            ans[1] = two[m - 1];
            for(int i = 2; i < m;i++)
            {
                ans[i] = (ans[i - 1] - ans[i - 2]) + m + ans[i - 1];
            }
        }
        cout << ans[m - 1];
    }
    return 0;
}
