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