#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, r;
  cin >> k >> r;
  int ans = 1;
  int tmp = k;
  while (tmp % 10 != r && tmp % 10 != 0) {
    ans++;
    tmp = (tmp + k) % 10;
  }
  cout << ans;
  return 0;
}
