#include <iostream>
using namespace std;
int main() {
int arr[1000][1000], n, m, count1 = 1, count2 = 1, result = 0;
cin >> n >> m;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
arr[i][j] = count1++;
for (int j = 0; j < m; j++) {
for (int i = 0; i < n; i++) {
if (arr[i][j] == count2) result++;
count2++;
}
}
cout << result << "\n";
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CiAgaW50IGFyclsxMDAwXVsxMDAwXSwgbiwgbSwgY291bnQxID0gMSwgY291bnQyID0gMSwgcmVzdWx0ID0gMDsKICBjaW4gPj4gbiA+PiBtOwogIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKQogICAgZm9yIChpbnQgaiA9IDA7IGogPCBtOyBqKyspCiAgICAgIGFycltpXVtqXSA9IGNvdW50MSsrOwogIGZvciAoaW50IGogPSAwOyBqIDwgbTsgaisrKSB7CiAgICBmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKykgewogICAgICBpZiAoYXJyW2ldW2pdID09IGNvdW50MikgcmVzdWx0Kys7CiAgICAgIGNvdW50MisrOwogICAgfQogIH0KICBjb3V0IDw8IHJlc3VsdCA8PCAiXG4iOwp9