#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, ans = 1;
  cin >> n >> m;
  while (ans) {
    if ((ans * n) % 10 == m || (ans * n) % 10 == 0) break;
    ans++;
  }
  cout << ans;
  return 0;
}
