#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y, sum = 0, t = 1;
  cin >> x >> y;
  while (t) {
    sum = t * x;
    if (sum % 10 == 0) {
      cout << t;
      return 0;
    } else if ((sum - y) % 10 == 0) {
      cout << t;
      return 0;
    }
    t++;
  }
  return 0;
}
