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