#include <bits/stdc++.h>
int main() {
  int a, b, c, z_1, z_2;
  int k[10];
  k[0] = 0;
  k[1] = 3;
  k[2] = 6;
  k[3] = 7;
  k[4] = 8;
  k[5] = 10;
  k[6] = 12;
  scanf("%d %d", &a, &b);
  c = fabs(a - b);
  if (c <= 3) {
    if (c == 3)
      printf("4\n");
    else
      printf("%d\n", c);
  } else {
    z_1 = (c - 3) / 6;
    z_2 = (c - 3) % 6;
    printf("%d\n", z_1 * k[6] + k[z_2]);
  }
  return 0;
}
