#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, r, x = 10000000;
  cin >> k >> r;
  for (int i = 1; i < 10; i++) {
    if (((k * i) % 10 == 0) || ((k * i) % 10 == r)) x = min(x, i);
  }
  cout << x << endl;
  return 0;
}
