#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int k, r, mult, output = 10;
  cin >> k >> r;
  int mod = k % 10;
  if ((mod == 0 || mod % r == 0) && r != 1 && k >= 10)
    cout << 1 << endl;
  else {
    for (int i = 1; i < 10; i++) {
      mult = mod * i;
      if (((mult % 10) - r == 0) || (mult % 10 == 0)) {
        output = i;
        break;
      }
    }
    cout << output << endl;
  }
}
