#include <bits/stdc++.h>
using namespace std;
const int N = 50;
const int inf = 0x3f3f3f3f;
const long long mod = 998244353LL;
clock_t TIME_START, TIME_END;
void program_end() {}
long long n, m;
void solve() {
  long long ans = 0;
  cin >> n >> m;
  if (n > m) swap(n, m);
  if (n == 2 && m == 3)
    ans = 4;
  else if (n == 2 && m == 2)
    ans = 0;
  else if (n == 1)
    ans = (m / 6 * 6 + max(0LL, m % 6 - 3) * 2);
  else if (n == 3 && m == 3)
    ans = 8;
  else if (n == 2 && m == 5)
    ans = 10;
  else if ((n >= 4 && n % 2 == 0) || (m >= 4 && m % 2 == 0))
    ans = n * m;
  else if ((n % 2 == 0) && (m % 5 == 0))
    ans = n * m;
  else if (n % 2 == 1 && m % 2 == 1)
    ans = n * m - 1;
  else if (n == 2 && m == 7)
    ans = 12;
  else if (n == 2)
    ans = n * m;
  cout << ans << endl;
}
int main() {
  TIME_START = clock();
  int Test = 1;
  while (Test--) solve();
  TIME_END = clock();
  program_end();
  return 0;
}
