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