#include <bits/stdc++.h>
using namespace std;
long long k, r, r1, k1, s, sum;
vector<int> v;
int main() {
  cin >> k >> r;
  k1 = k;
  while (1) {
    s = (k - r) / 10;
    if ((k - r) % 10 != 0)
      sum = 10 * s + 10 + r;
    else
      sum = 10 * s + r;
    if (k % 10 != 0 && sum != k)
      k = k + k1;
    else {
      cout << k / k1;
      return 0;
    }
  }
}
