#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k, c = 1, ar[100009];
  cin >> n >> k;
  while (1) {
    if (((n * c) % 10 == 0) || ((n * c) % 10 == k)) {
      cout << c;
      break;
    }
    c++;
  }
  return 0;
}
