#include <bits/stdc++.h>
using namespace std;
const int N = 10, M = 1e6;
long long n, m, dp[N][N];
bool mark[M];
int main() {
  dp[2][3] = 4;
  dp[2][4] = 8;
  dp[2][5] = 10;
  dp[2][6] = 12;
  dp[2][7] = 12;
  dp[3][3] = 8;
  dp[3][4] = 12;
  dp[3][5] = 14;
  cin >> n >> m;
  if (n > m) swap(n, m);
  if (n > 3 && m > 3)
    cout << n * m - ((n * m) & 1);
  else if (n < 3 && m < 3)
    cout << 0;
  else if (n < N && m < N && dp[n][m])
    cout << dp[n][m];
  else if (n == 1) {
    if (m % 6 < 4)
      cout << m - m % 6;
    else if (m % 6 == 4)
      cout << m - 2;
    else if (m % 6 == 5)
      cout << m - 1;
  } else if (n == 2) {
    cout << n * m;
  } else {
    if (m & 1)
      cout << n * m - ((n * m) & 1);
    else
      cout << n * m;
  }
  return 0;
}
