#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, p, c = 1;
  cin >> a >> b;
  p = a;
  while (1) {
    if (a % 10 == 0) break;
    if (a % 10 == b) break;
    a = a + p;
    c++;
  }
  cout << c;
}
