#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define f first
#define s second
#define pb push_back
#define sz(x) (int) x.size()
#define all(x) begin(x), end(x)
 
using namespace std;
 
const int N = 2e5 + 1, inf = LLONG_MAX / 2ll ;
map <int,int> kol;
set <int> was;
int calc(int x) {
    if(x == 1) return 1;
    if(was.find(x) != was.end()) return kol[x];
    if(x % 2 == 0) {
        was.insert(x);
        return kol[x] = x + + calc(x - 1) + 1;
    }
    else {
        was.insert(x);
        return kol[x] = x + calc(x - 1) + 1;
    }
}
void solve() {
    int n,m;
    cin >> n >> m;
    int x = 1,y = 1;
    int ans = 1;
    while(x + y != n + m) {
        if(y == m) {
            x++;
            ans+=x*y;
            ans+=calc(y);
        }
        else if(x == n) {
            y++;
            ans+=y*x;
            ans+=calc(x);
        }
        else if(x > y) {
            y++;
            ans+=y*x;
            ans+=calc(x);
        }
        else {
            x++;
            ans+=x*y;
            ans+=calc(y);
        }
    }
    cout << ans << endl;
}
 
signed main() {
    srand(time(0)) ;
    ios_base::sync_with_stdio(NULL);
    cin.tie(0);cout.tie(0);
    int T = 1 ;
    // cin >> T ;
    while (T--) {
        solve ( ) ;
    }
    return 0 ;
}