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