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