#include <bits/stdc++.h>
const int maxn = 3e5 + 5;
using namespace std;
long long n, m;
int main() {
  scanf("%d%d", &n, &m);
  if (min(n, m) == 1) {
    long long t = max(n, m);
    long long ti = t / 6, res = t % 6;
    printf("%lld\n", ti * 6 + max(0ll, res - 3) * 2);
    return 0;
  }
  if ((n % 2) && (m % 2)) {
    printf("%lld\n", n * m - 1);
  } else if (n % 2 == 0 && m % 2 == 0) {
    if (max(n, m) <= 2)
      printf("0\n");
    else
      printf("%lld\n", n * m);
  } else {
    if (min(n, m) == 2) {
      long long t = max(n, m);
      if (t == 3 || t == 7)
        printf("%lld\n", n * m - 2);
      else
        printf("%lld\n", n * m);
    } else
      printf("%lld\n", n * m);
  }
  return 0;
}
