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