#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b;
  cin >> a >> b;
  long long c;
  c = a;
  while (1) {
    if ((a - b) % 10 == 0 || a % 10 == 0) {
      cout << a / c;
      break;
    }
    a += c;
  }
  return 0;
}
