#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  scanf("%lld%lld", &n, &m);
  if (n > m) swap(n, m);
  long long ans = 0;
  if (n == 1) {
    switch (m % 6) {
      case 0:
        break;
      case 1:
      case 5:
        ans--;
        break;
      case 2:
      case 4:
        ans -= 2;
        break;
      case 3:
        ans -= 3;
        break;
    }
  } else if (n == 2) {
    if (m == 2)
      ans = -4;
    else if (m == 1 || m == 3 || m == 7)
      ans = -2;
  } else if ((n * m) & 1)
    ans--;
  ans += n * m;
  printf("%lld\n", ans);
  return 0;
}
