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