#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
  int k, r, min;
  cin >> k >> r;
  for (min = 1; min <= 10; min++) {
    if (k * min % 10 == 0 || k * min % 10 == r) break;
  }
  cout << min;
}
