#include <bits/stdc++.h>
int INF = 2147483647;
double INFD = 2147483647;
double PI = 3.14159265359;
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int k = 0, r = 0, c = 0, resto = 0, t = 0, change = 0;
  cin >> k >> r;
  t = ceil((double)k / 10.0);
  while (true) {
    if ((k - resto) % 10 == 0 || (k - resto - r) % 10 == 0) {
      c++;
      break;
    }
    resto += t * 10 - k;
    c++;
    if (!resto || resto == k || resto + r == k) {
      c += (resto == k || resto + r == k) ? 1 : 0;
      break;
    }
  }
  cout << c << endl;
  return 0;
}
