#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000001;
long long int go(long long int n, long long int m) {
  if (n == 1) {
    if (m % 6 == 1) return n * m - 1ll;
    if (m % 6 == 2) return n * m - 2ll;
    if (m % 6 == 3) return n * m - 3ll;
    if (m % 6 == 4) return n * m - 2ll;
    if (m % 6 == 5) return n * m - 1ll;
    return n * m;
  }
  if (m % 6 == 0) return n * m;
  if (n == 2) {
    if (m == 1) return n * m - 2ll;
    if (m == 2) return n * m - 4ll;
    if (m == 3) return n * m - 2ll;
    if (m == 7) return n * m - 2ll;
    return n * m - 0ll;
  }
  if (!(n & 1) && m != 1 && m != 2 && m != 3 && m != 7) return n * m;
  if (m == 1) return go(m, n);
  if (m == 2) return go(m, n);
  long long int aux = (n / 3ll), ans;
  if (m & 1) ans = aux * 3ll * m - aux * 1;
  if (!(m & 1)) ans = aux * 3ll * m - aux * 0;
  if (n % 3 != 0) ans += go(n % 3, m);
  long long int ans2 = go(1, m) * n;
  long long int aux2 = n / 2;
  long long int ans3 = go(2, m) * aux2 + (n & 1 ? go(1, m) : 0ll);
  return max(ans, max(ans2, ans3));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long int n, m;
  cin >> n >> m;
  cout << max(go(n, m), go(m, n)) << '\n';
  return 0;
}
