#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, r;
  cin >> k >> r;
  for (long long i = 1; i < 1e9; i++) {
    long long num = (i * k) % 10;
    if (num == r || num == 0) {
      cout << i << endl;
      return 0;
    }
  }
}
