#include <bits/stdc++.h>
using namespace std;
const int M = 15000000;
int main() {
  long long n, m;
  cin >> n >> m;
  int res[5][5];
  res[1][0] = 0;
  res[1][1] = 0;
  res[1][2] = 0;
  res[1][3] = 0;
  res[1][4] = 2;
  res[2][1] = 0;
  res[2][2] = 0;
  res[2][3] = 4;
  res[2][4] = 8;
  res[3][1] = 0;
  res[3][2] = 4;
  res[3][3] = 8;
  res[3][4] = 12;
  res[4][1] = 2;
  res[4][2] = 8;
  res[4][3] = 12;
  res[4][4] = 16;
  if (m <= 4 && n <= 4)
    cout << res[m][n] << endl;
  else if (m == 2 || n == 2)
    cout << m * n - (m + n == 9 ? 2 : 0) << endl;
  else if (n == 1 || m == 1)
    cout << m * n - (m * n) % 6 +
                ((m * n) % 6 > 4 ? (m * n) % 6 - (m * n) % 2
                                 : res[1][(m * n) % 6])
         << endl;
  else
    cout << m * n - (m * n) % 2 << endl;
}
