#include <bits/stdc++.h>
using namespace std;
const int MAX = 3 * 1e5 + 5, MAXP = 1e7 + 5 * 1e6 + 5, INF = 1e9,
          MOD = 998244353;
int n, m;
int main() {
  cin >> n >> m;
  if (n > m) swap(n, m);
  if (n % 6 == 0 || m % 6 == 0)
    cout << (long long)n * m;
  else if (n == 1 && m == 4)
    cout << 2;
  else if (n == 1 && m == 2)
    cout << 0;
  else if (n == 2 && m == 2)
    cout << 0;
  else if (n == 2 && m == 3)
    cout << 4;
  else if (n == 1 && m == 3)
    cout << 0;
  else if (n == 1 && m % 6 == 3)
    cout << (long long)n * m - 3;
  else if (n == 1 && m % 6 == 2)
    cout << (long long)n * m - 2;
  else if (n == 1 && m % 6 == 4)
    cout << (long long)n * m - 2;
  else if (n == 2 && m == 7)
    cout << (long long)n * m - 2;
  else if (n % 2 == 0 || m % 2 == 0)
    cout << (long long)n * m;
  else
    cout << (long long)n * m - 1;
  return 0;
}
