#include <bits/stdc++.h>
using namespace std;
void solve() {
  int k, r;
  cin >> k >> r;
  int ans = 1;
  while ((k * ans) % 10 != r && (k * ans) % 10 != 0) {
    ans++;
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int test_cases;
  test_cases = 1;
  while (test_cases--) {
    solve();
  }
  return 0;
}
