#include <bits/stdc++.h>
using namespace std;
const int LIM = 15000002;
vector<vector<int> > gen(int N, int M) {
  vector<vector<int> > V(N, vector<int>(M));
  int bid = 0, wid = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < M; ++j) {
      if ((i + j) % 2 == 0) {
        V[i][j] = wid++;
      } else {
        V[i][j] = bid++;
      }
    }
  }
  return V;
}
int findMatch(int u, vector<int> &VIS, vector<vector<int> > &adj,
              vector<int> &MA) {
  if (VIS[u]) return 0;
  VIS[u] = 1;
  for (int v : adj[u]) {
    if (MA[v] == -1 || findMatch(MA[v], VIS, adj, MA)) {
      MA[v] = u;
      return 1;
    }
  }
  return 0;
}
int maxMatching(vector<vector<int> > &adj) {
  vector<int> VIS(adj.size());
  vector<int> MA(adj.size(), -1);
  int m = 0;
  for (int i = 0; i < adj.size(); ++i) {
    VIS = vector<int>(adj.size());
    m += findMatch(i, VIS, adj, MA);
  }
  return m;
}
int main() {
  long long N = 10, M = 10;
  cin >> N >> M;
  if (N == 2 && M == 2) {
    cout << 0 << endl;
  } else if ((N == 2 && M == 3) || (N == 3 && M == 2)) {
    cout << 4 << endl;
  } else if ((N == 2 && M == 7) || (N == 7 && M == 2)) {
    cout << 12 << endl;
  } else if (N == 1 || M == 1) {
    if (M == 1) swap(M, N);
    long long t = M / 6 * 6;
    M %= 6;
    if (M >= 4) {
      M %= 3;
      t += 2 * M;
    }
    cout << t << endl;
  } else {
    cout << N * M / 2 * 2 << endl;
  }
  return 0;
  for (N = 2; N <= 40; ++N) {
    for (M = 2; M <= 40; ++M) {
      vector<vector<int> > ID = gen(N, M);
      vector<vector<int> > adj(N * M);
      for (int i = 0; i < N; ++i) {
        for (int j = 0; j < M; ++j) {
          if ((i + j) % 2 != 0) continue;
          for (int k = 0; k < N; ++k) {
            for (int l = 0; l < M; ++l) {
              if (abs(i - k) + abs(j - l) == 3) {
                int u = ID[i][j], v = ID[k][l];
                adj[u].push_back(v);
              }
            }
          }
        }
      }
      int t = maxMatching(adj);
      if (t * 2 != N * M && N * M - t * 2 != 1) {
        cout << t * 2 << " " << N << " " << M << endl;
        ;
      }
    }
  }
  return 0;
}
