#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int X = 0, w = 1;
  char ch = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    X = (X << 3) + (X << 1) + ch - '0', ch = getchar();
  return X * w;
}
int main() {
  long long x = read(), y = read();
  if (x > y) {
    swap(x, y);
  }
  if (x == 1) {
    if (y <= 3) {
      puts("0");
    } else {
      long long k = y % 6;
      if (k <= 3) {
        printf("%I64d", y - k);
      } else if (k == 4) {
        printf("%I64d", y - k + 2);
      } else {
        printf("%I64d", y - k + 4);
      }
    }
  } else if (x == 2) {
    if (y == 2) {
      puts("0");
    } else if (y == 3) {
      puts("4");
    } else if (y == 7) {
      puts("12");
    } else {
      long long z = x * y;
      cout << z;
    }
  } else if (x == 3 && y == 3) {
    puts("8");
  } else {
    long long z = x * y;
    if (z & 1) {
      z--;
    }
    cout << z;
  }
  return 0;
}
