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