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