#include <bits/stdc++.h>
using namespace std;
int main() {
  int k;
  int r;
  cin >> k >> r;
  int c = 1;
  int s = k;
  if (s % 10 == 0)
    cout << c;
  else {
    while ((s - r) % 10) {
      s += k;
      c++;
      if (s % 10 == 0) break;
    }
    cout << c;
  }
}
