#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if (a % 10 == 0 || a % 10 == b) {
    cout << "1" << endl;
    return 0;
  }
  int t = 2;
  long long int c;
  c = a;
  while (!(c % 10 == 0 || c % 10 == b)) {
    c = a % 10;
    c = c * t;
    t++;
  }
  cout << t - 1 << endl;
}
