#include <bits/stdc++.h>
using namespace std;
int k, r, ans, tmp;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> k >> r;
  for (tmp = k, ans = 1; tmp % 10 != r && tmp % 10 != 0; tmp += k, ans++)
    ;
  cout << ans << '\n';
  return 0;
}
