#include <bits/stdc++.h>
using namespace std;
const long long N = 1e4 + 7;
vector<long long> g[N];
long long used[N], match[N];
bool kun(long long v, long long cnt) {
  used[v] = cnt;
  for (long long u : g[v]) {
    if (match[u]) {
      if (used[match[u]] != cnt && kun(match[u], cnt)) {
        match[u] = v;
        return true;
      }
    } else {
      match[u] = v;
      return true;
    }
  }
  return false;
}
void solve() {
  long long n, m;
  cin >> n >> m;
  if (n > m) swap(n, m);
  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;
    return;
  }
  if (n > 100 || m > 100) {
    cout << n * m - (n % 2 && m % 2);
    return;
  }
  for (long long i = 0; i < (long long)n; ++i)
    for (long long j = 0; j < (long long)m; ++j) {
      long long v = m * i + j + 1;
      long long x = i - 3, y = j;
      for (long long k = 0; k < (long long)3; ++k) {
        if (x >= 0 && y >= 0 && x < n && y < m) g[v].push_back(m * x + y + 1);
        ++x;
        ++y;
      }
      for (long long k = 0; k < (long long)3; ++k) {
        if (x >= 0 && y >= 0 && x < n && y < m) g[v].push_back(m * x + y + 1);
        ++x;
        --y;
      }
      for (long long k = 0; k < (long long)3; ++k) {
        if (x >= 0 && y >= 0 && x < n && y < m) g[v].push_back(m * x + y + 1);
        --x;
        --y;
      }
      for (long long k = 0; k < (long long)3; ++k) {
        if (x >= 0 && y >= 0 && x < n && y < m) g[v].push_back(m * x + y + 1);
        --x;
        ++y;
      }
    }
  long long cnt = 0;
  for (long long i = 0; i < (long long)n; ++i)
    for (long long j = 0; j < (long long)m; ++j)
      if ((!(i % 2) && !(j % 2)) || (i % 2 && j % 2)) kun(m * i + j + 1, cnt++);
  long long is_full = 0;
  for (long long i = 0; i < (long long)n; ++i)
    for (long long j = 0; j < (long long)m; ++j)
      if (match[m * i + j + 1]) is_full += 2;
  cout << is_full;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
