#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y, i = 1, s, p, q;
  cin >> x >> y;
  s = x % 10;
  q = s;
  p = s;
  while (p % 10 != 0 || p != y) {
    if (p % 10 == 0 || p == y) {
      break;
    }
    i++;
    q = q + s;
    p = q % 10;
  }
  cout << i;
}
