#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, kk, kn, num;
  cin >> k >> n;
  k = k % 10;
  for (int i = 1;; i++) {
    kk = k * i;
    kn = kk % 10;
    if (kn - n == 0 || kn % 10 == 0) {
      num = i;
      break;
    }
  }
  cout << num;
}
