#include <iostream>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <string.h>
#include <unordered_map>
#include <stack>
#include <set>
using namespace std;
int n, m, a[50][50], mx;
void dfs(int x, int y, int step) {
int count = 0;
for (int i = x - 1; i >= 0; i--) {
if (a[i][y] == 1) {
count++;
}
if (count == 2) {
a[i][y] = 0;
dfs(i, y, step + 1);
a[i][y] = 1;
break;
}
}
count = 0;
for (int i = x + 1; i < n; i++) {
if (a[i][y] == 1) {
count++;
}
if (count == 2) {
a[i][y] = 0;
dfs(i, y, step + 1);
a[i][y] = 1;
break;
}
}
count = 0;
for (int i = y - 1; i >= 0; i--) {
if (a[x][i] == 1) {
count++;
}
if (count == 2) {
a[x][i] = 0;
dfs(x, i, step + 1);
a[x][i] = 1;
break;
}
}
count = 0;
for (int i = y + 1; i < m; i++) {
if (a[x][i] == 1) {
count++;
}
if (count == 2) {
a[x][i] = 0;
dfs(x, i, step + 1);
a[x][i] = 1;
break;
}
}
if (step > mx) mx = step;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
a[i][j] = 1;
}
}
a[0][0] = 0;
mx = 0;
dfs(0, 0, 0);
cout << mx;
}