#include <bits/stdc++.h>
using namespace std;
inline long long getnum() {
  char c = getchar();
  long long num, sign = 1;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') sign = -1;
  for (num = 0; c >= '0' && c <= '9';) {
    c -= '0';
    num = num * 10 + c;
    c = getchar();
  }
  return num * sign;
}
int main() {
  int n = getnum(), m = getnum();
  int ans = 0;
  while (1) {
    if ((ans * n) % 10 == 0 && ans > 0) {
      cout << ans;
      return 0;
    }
    if ((ans * n - m) % 10 == 0) {
      cout << ans;
      return 0;
    }
    ans++;
  }
}
