//By Don4ick #include const long long INF = (long long)1e18+ 228; using namespace std; long long n, m, ans = INF; int main() { cin >> n >> m; if (n == 1 && m == 1) ans = 0; if (n == 1) ans = m - 1; if (m == 1) ans = n - 1; if (n != 1 && m != 1) ans = min((n - 1) + (n * (m - 1)), (m - 1) + (m * (n - 1))); cout << ans; return 0; }