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