#include <bits/stdc++.h>
using namespace std;
static auto _ = [] {
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cerr.tie(nullptr);
  return nullptr;
};
int main() {
  int k, r;
  cin >> k >> r;
  int i = 1;
  while (((k * i) % 10 != r) && ((k * i) % 10 != 0)) i++;
  cout << i << endl;
  return 0;
}
