#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return b * a / gcd(a, b);
}
long long int abs1(long long int a) {
  if (a < 0)
    return -1 * a;
  else
    return a;
}
long long int max(long long int a, long long int b) {
  if (a > b) return a;
  return b;
}
long long int fast_pow(long long base, long long n) {
  if (n == 0) return 1;
  if (n == 1) return base;
  long long halfn = fast_pow(base, n / 2);
  if (n % 2 == 0)
    return (halfn * halfn);
  else
    return (((halfn * halfn)) * base);
}
long long int findMMI_fermat(long long int n, long long int M) {
  return fast_pow(n, M - 2);
}
const double PI = 3.14159265358979323846;
int main() {
  long long int k, r;
  cin >> k >> r;
  int p = k;
  int count = 1;
  while (1) {
    if (k % 10 == 0) {
      break;
    }
    if (k % 10 == r) break;
    count++;
    k += p;
  }
  cout << count;
  return 0;
}
