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