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