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