#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, r;
  int total = 1;
  cin >> k >> r;
  int g = k;
  for (int i = 0; i < 1000; i++) {
    if (r == k % 10) {
      cout << total << endl;
      break;
    } else if (k % 10 == 0) {
      cout << total << endl;
      break;
    } else {
      k += g;
      total++;
    }
  }
  return 0;
}
