#include <bits/stdc++.h>
using namespace std;
int read() {
  int j;
  char c;
  for (c = getchar(); !isdigit(c); c = getchar())
    ;
  for (j = 0; isdigit(c); j = (j << 1) + (j << 3) + (c ^ 48), c = getchar())
    ;
  return j;
}
void write(int x) {
  char c[20];
  int l = 0;
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  do {
    c[++l] = x % 10 + 48;
    x /= 10;
  } while (x);
  do {
    putchar(c[l--]);
  } while (l);
}
signed main() {
  int n = read(), k = read();
  if (n == 1) {
    cout << 0 << "\n";
  }
  if (n == 2) {
    write((k <= 4) ? 6 : 8);
  }
}
