#include #include #include #include #include using namespace std; int main() { long long n, m; while(cin >> n >> m){ if(n == 1 || m == 1){ cout << (m-1) + (n-1) << endl; continue; } long long ans1 = (n-1) + n * (m-1), ans2 = (m-1) + m * (n-1); cout << min(ans1, ans2) << endl; } return 0; }