#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int N = 3e5 + 5;
const int Limit = 15000005;
int grid[10][10];
int n, m;
int dx[] = {0, 1, 2, 3};
int dy[] = {3, 2, 1, 0};
bool ok(int x, int y) {
  if (x >= n || y >= m || x < 0 || y < 0 || grid[x][y]) return false;
  return true;
}
int bt() {
  int ret = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (grid[i][j]) continue;
      for (int k = 0; k < 4; k++) {
        for (int k1 = -1; k1 <= 1; k1 += 2) {
          for (int k2 = -1; k2 <= 1; k2 += 2) {
            int nx = i + dx[k] * k1;
            int ny = j + dy[k] * k2;
            if (ok(nx, ny)) {
              grid[i][j] = grid[nx][ny] = 1;
              ret = max(ret, 1 + bt());
              grid[i][j] = grid[nx][ny] = 0;
            }
          }
        }
      }
    }
  }
  return ret;
}
int main() {
  cin >> n >> m;
  if (n == 4 && m == 4) {
    cout << n * m << '\n';
    return 0;
  }
  if (n <= 4 && m <= 4) {
    cout << bt() * 2 << '\n';
    return 0;
  }
  if (n > m) swap(n, m);
  if (n == 1) {
    cout << m - m % 6 + (m % 6 > 3) * 2 + (m % 6 > 4) * 2 << '\n';
  } else {
    if (m % 4 == 0 || n % 4 == 0 || m % 4 == 2) {
      cout << n * 1ll * m << '\n';
      return 0;
    }
    if (n == 2) {
      if (m == 7)
        cout << n * 1ll * m - 2 << '\n';
      else
        cout << n * 1ll * m << '\n';
      return 0;
    }
    if (n % 4 == 2) {
      cout << n * 1ll * m << '\n';
      return 0;
    }
    if (n % 4 == 1 && m % 4 == 1) {
      cout << n * 1ll * m - 1 << '\n';
      return 0;
    }
    if (n % 4 == 3 && m % 4 == 1) {
      cout << n * 1ll * m - 1 << '\n';
      return 0;
    }
    if (n % 4 == 3 && m % 4 == 3) {
      cout << n * 1ll * m - 1 << '\n';
      return 0;
    }
    if (n % 4 == 1 && m % 4 == 3) {
      cout << n * 1ll * m - 1 << '\n';
      return 0;
    }
  }
  return 0;
}
