#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, r;
  scanf("%d %d", &k, &r);
  int ans = 1, t = k;
  while (k % 10 != r && k % 10 != 0) {
    k += t;
    ans++;
  }
  printf("%d\n", ans);
  return 0;
}
