#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e6 + 5000;
const long double eps = (1e-12);
const int logn = 21;
const double Pi = acos(-1.0);
const long long pp = 998244353;
int lowbit(int x) { return x & (-x); }
const long long INF = 1e9;
long long n, m;
signed main() {
  scanf("%lld%lld", &n, &m);
  long long ans = 0;
  if (n > m) swap(n, m);
  if (n == 1) {
    ans = m / 6 * 6;
    m %= 6;
    if (m == 4)
      ans += 2;
    else if (m == 5)
      ans += 4;
  } else {
    if (n == 2 && m == 2)
      ans = 0;
    else if (n == 2 && m == 3)
      ans = 4;
    else if (n == 3 && m == 3)
      ans = 8;
    else {
      ans = n * m;
      if (n == 2) {
        if (m == 7) ans -= 2;
      } else {
        if (ans % 2 == 1) {
          ans -= 1;
        }
      }
    }
  }
  printf("%lld", ans);
  return 0;
}
