#include <bits/stdc++.h>
using namespace std;
bool compare(const pair<int, int> &i, const pair<int, int> &j) {
  return (i.second == j.second) ? (i.first < j.first) : (i.second < j.second);
}
const long long mod = 1e9 + 7;
int main() {
  int k, r;
  cin >> k >> r;
  for (int i = 1; i <= 10; i++) {
    if (i * k % 10 == 0 or i * k % 10 == r) {
      cout << i;
      return 0;
    }
  }
}
