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