#include <bits/stdc++.h>
using namespace std;
vector<string> split(const string &s, char c) {
  vector<string> v;
  stringstream ss(s);
  string x;
  while (getline(ss, x, c)) v.push_back(x);
  return v;
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cerr << "[DEBUG] " << it->substr((*it)[0] == ' ', it->length()) << " = " << a
       << '\n';
  err(++it, args...);
}
const int MOD = 1000000007;
template <class T, class U>
inline T tmin(T a, U b) {
  return (a < b) ? a : b;
}
template <class T, class U>
inline T tmax(T a, U b) {
  return (a > b) ? a : b;
}
template <class T, class U>
inline void amax(T &a, U b) {
  if (b > a) a = b;
}
template <class T, class U>
inline void amin(T &a, U b) {
  if (b < a) a = b;
}
template <class T>
T gcd(T a, T b) {
  while (b != 0) {
    T c = a;
    a = b;
    b = c % b;
  }
  return a;
}
const int N = 105;
struct BP {
  vector<int> G[N];
  int match[N];
  bool used[N];
  int V;
  void add_edge(int u, int v) {
    G[u].push_back(v);
    G[v].push_back(u);
  }
  bool dfs(int v) {
    used[v] = true;
    for (int u : G[v]) {
      int w = match[u];
      if (w < 0 || !used[w] && dfs(w)) {
        match[v] = u;
        match[u] = v;
        return true;
      }
    }
    return false;
  }
  int bipartite_matching() {
    int res = 0;
    memset(match, -1, sizeof(match));
    for (int v = (0); v < (V); ++v) {
      if (match[v] < 0) {
        memset(used, 0, sizeof(used));
        if (dfs(v)) res++;
      }
    }
    return res;
  }
};
inline void ok(long long x) { cout << x << endl; }
inline int enc(int r, int c, int n) { return n * r + c; }
int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  if (n > m) swap(n, m);
  long long tot = n * m, ans = 0;
  if (n >= 5) {
    ans = tot;
    if (tot % 2 == 1) ans--;
    ok(ans);
    return 0;
  }
  if (n == 1) {
    if (m < 4)
      ;
    else if (m == 4)
      ans = 2;
    else if (m == 5)
      ans = 4;
    else if (m >= 6) {
      ans = tot / 6 * 6;
      tot %= 6;
      if (tot == 4)
        ans += 2;
      else if (tot == 5)
        ans += 4;
    }
  } else if (n == 2) {
    if (m == 2)
      ans = 0;
    else {
      if (m % 4 == 0 || m % 4 == 1 || m % 4 == 2)
        ans = tot;
      else {
        if (m == 3 || m == 7)
          ans = tot - 2;
        else
          ans = tot;
      }
    }
  } else if (n == 3) {
    if (m == 3)
      ans = tot - 1;
    else if (m == 4)
      ans = tot;
    else if (m == 5)
      ans = tot - 1;
    else {
      if (m % 4 == 0)
        ans = tot;
      else if (m % 4 == 1)
        ans = tot - 1;
      else if (m % 4 == 2)
        ans = tot;
      else
        ans = tot - 1;
    }
  } else if (n == 4) {
    ans = tot;
  }
  ok(ans);
  return 0;
}
