#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e5 + 10;
const long long MOD = 1e9 + 7;
bool isprime(long long number) {
  if (number < 2) return false;
  if (number == 2) return true;
  if (number % 2 == 0) return false;
  for (long long i = 3; (i * i) <= number; i += 2)
    if (number % i == 0) return false;
  return true;
}
void solve() {
  long long n, k;
  cin >> n >> k;
  for (long long i = 1; i < 11; i += 1)
    if ((n * i - k) % 10 == 0 || (n * i) % 10 == 0) {
      cout << i;
      return;
    }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  { solve(); }
  return 0;
}
