#include <bits/stdc++.h>
using namespace std;
void fact(int n) {
  const int N = 1e5;
  vector<int> arr(N, 0);
  int q = 2;
  arr[0] = 1;
  int len = 1;
  int x = 0;
  int carry = 0;
  while (q <= n) {
    x = 0;
    carry = 0;
    while (x < len) {
      arr[x] = arr[x] * q + carry;
      carry = arr[x] / 10;
      arr[x] = arr[x] % 10;
      x++;
    }
    while (carry) {
      arr[len] = carry % 10;
      carry = carry / 10;
      len++;
    }
    q++;
  }
  len--;
  for (int i = len; i >= 0; i--) {
    cout << arr[i];
  }
  return;
}
long long int binary_exp(long long int x, long long int n) {
  if (n == 0) {
    return 1;
  } else if (n == 1) {
    return x % 1000000007;
  } else {
    long long int temp = binary_exp(x, n / 2);
    temp = (temp * temp) % 1000000007;
    if (n % 2 == 0) {
      return temp;
    } else {
      return ((x % 1000000007) * temp) % 1000000007;
    }
  }
}
int main() {
  int k, r;
  cin >> k >> r;
  int i = 1;
  while (i * k % 10 != r and i * k % 10 != 0) {
    i++;
  }
  cout << i;
  return 0;
}
