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