#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &V) {
  if (!V.empty()) {
    out << "{";
    for (auto v : V) out << v << ", ";
    out << "\b\b}";
  } else {
    out << "{}";
  }
  return out;
}
template <class T1, class T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &P) {
  out << "{" << P.first << ", " << P.second << "}";
  return out;
}
bool ldfs(int u, vector<bool> &Vis, vector<int> &M,
          vector<vector<int> > &Neigh) {
  if (Vis[u]) return false;
  Vis[u] = true;
  for (int v : Neigh[u])
    if (M[v] == -1 || ldfs(M[v], Vis, M, Neigh)) {
      M[u] = v;
      M[v] = u;
      return true;
    }
  return false;
}
long long count_not_matched_for(int n, int m) {
  vector<vector<int> > Neigh(n * m);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      for (int k = 0; k < n; k++)
        for (int l = 0; l < m; l++)
          if (abs(i - k) + abs(j - l) == 3)
            Neigh[i * m + j].push_back(k * m + l);
  bool incr = true;
  vector<int> M(n * m, -1);
  while (incr) {
    incr = false;
    vector<bool> Vis(n * m, false);
    for (int i = 0; i < n * m; i++)
      if (M[i] == -1 && ldfs(i, Vis, M, Neigh)) incr = true;
  }
  int not_matched = 0;
  for (int i = 0; i < n * m; i++)
    if (M[i] == -1) not_matched++;
  return not_matched;
}
void solve(int n, int m) {
  if (n > m) swap(n, m);
  if (n == 1) {
    int not_matched = count_not_matched_for(n, m % 6);
    cout << 1ll * n * m - not_matched << endl;
  } else if (n <= 20 && m <= 20) {
    int not_matched = count_not_matched_for(n, m);
    cout << 1ll * n * m - not_matched << endl;
  } else
    cout << 1ll * n * m - ((m % 2) & (n % 2)) << endl;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  solve(n, m);
  return 0;
}
