#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int n, k, ans = 0;
  scanf("%d %d", &n, &k);
  int cnt = 1;
  while (true) {
    if (cnt > 10) break;
    if (cnt * n % 10 == k or cnt * n % 10 == 0) {
      ans = cnt;
      break;
    }
    cnt++;
  }
  printf("%d\n", min(cnt, 10));
  return 0;
}
