#include <bits/stdc++.h>
int main(void) {
  int k, rem = 1, i = 2, r;
  scanf("%d %d", &k, &r);
  int p = k;
  while (1) {
    if (k % 10 == 0 || k % 10 == r) {
      printf("%d", rem);
      return 0;
    } else {
      k = p * i;
      rem++;
      i++;
    }
  }
}
