#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n, m;
  cin >> n >> m;
  if (m < n) {
    swap(n, m);
  }
  int excl = (n * m) % 2;
  if (n == 1) {
    int ans[] = {0, 1, 2, 3, 2, 1};
    excl = ans[m % 6];
  } else if (n == 2) {
    if (m == 2) {
      excl = 4;
    } else if (m == 1 || m == 3 || m == 7) {
      excl = 2;
    }
  }
  cout << n * m - excl << '\n';
  return 0;
}
