#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long maxn = 3e6;
const long long mod = 1e9 + 7;
const long double PI = acos((long double)-1);
long long pw(long long a, long long b, long long md = mod) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res = (a * res) % md;
    }
    a = (a * a) % md;
    b >>= 1;
  }
  return (res);
}
long long n, m;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  if (n >= 4 and m >= 4) return (cout << n * m / 2 * 2, 0);
  ;
  if (n > m) swap(n, m);
  if (n == 1) {
    if (m < 4) return (cout << 0, 0);
    ;
    long long ans = m - m % 6;
    ans += max(0LL, m % 6 - 3) * 2;
    return (cout << ans, 0);
    ;
  }
  if (n == 2) {
    if (m % 5 == 0) return (cout << m * n, 0);
    ;
    if (m % 4 == 0) return (cout << n * m, 0);
    ;
    if (m % 6 == 0) return (cout << n * m, 0);
    ;
    if (m <= 2) return (cout << 0, 0);
    ;
    if (m == 3) return (cout << 4, 0);
    ;
    if (m == 4) return (cout << 8, 0);
    ;
    if (m == 7) return (cout << 12, 0);
    ;
    return (cout << n * m, 0);
    ;
  }
  return (cout << n * m / 2 * 2, 0);
  ;
  return (0);
}
