#include <bits/stdc++.h>
using namespace std;
struct point {
  double x, y;
  point() {
    x = 0;
    y = 0;
  }
  point(double a, double b) {
    x = a;
    y = b;
  }
  double getLength() { return sqrt(x * x + y * y); }
};
double cross_product(point a, point b) { return (a.x * b.y - a.y * b.x); }
double dot_product(point a, point b) { return (a.x * b.x + a.y * b.y); }
point operator+(point a, point b) { return point(a.x + b.x, a.y + b.y); }
point operator-(point a, point b) { return point(a.x - b.x, a.y - b.y); }
point operator*(point a, double b) { return point(a.x * b, a.y * b); }
point operator/(point a, double b) { return point(a.x / b, a.y / b); }
istream &operator>>(istream &is, point &p) {
  is >> p.x >> p.y;
  return is;
}
int k, r;
int main() {
  scanf("%d%d", &k, &r);
  if (k % 10 == 0) {
    printf("1");
    return 0;
  }
  for (int i = 1; i <= 10; i++) {
    if ((k * i - r) % 10 == 0 || (k * i) % 10 == 0) {
      printf("%d", i);
      return 0;
    }
  }
}
