#include <bits/stdc++.h>
using namespace std;
const double PI = 3.1415926535898;
const double E = 2.718281828459;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  long long ans = 0;
  if (n > 2 && m > 2) {
    ans = n * m;
    long long ma = max(n, m);
    if ((n % 2 == 1) && (m % 2 == 1)) ans--;
  } else if (n > 2 || m > 2) {
    long long ma = max(n, m);
    long long mi = min(n, m);
    if (mi == 1) {
      ans += ma / 6 * 6;
      if (ma % 6 == 5)
        ans += 4;
      else if (ma % 6 == 4)
        ans += 2;
    } else {
      if (ma != 7 && ma != 3)
        ans += 2 * ma;
      else if (ma == 7)
        ans += 2 * 7 - 2;
      else if (ma == 3)
        ans += 4;
    }
  }
  cout << ans << endl;
  return 0;
}
