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