#include <bits/stdc++.h>
using namespace std;
long long n, m, ans;
int main() {
  scanf("%lld%lld", &n, &m);
  if (n > m) swap(n, m);
  if (n == 1)
    printf("%d\n", max((m % 6 - 3), 0ll) * 2 + m / 6 * 6);
  else if (n == 2) {
    if (m == 2)
      puts("0");
    else if (m == 3)
      puts("4");
    else if (m == 7)
      puts("12");
    else
      printf("%lld\n", m * 2);
  } else if (n & 1 && m & 1)
    printf("%lld\n", n * m - 1);
  else
    printf("%lld\n", n * m);
}
