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