#include <bits/stdc++.h>
using namespace std;
int n, m, ans = 1, d;
int main() {
  cin >> n >> m;
  d = n % 10;
  while (d % 10 != m && d % 10 != 0) {
    d += (n % 10);
    ans++;
  }
  cout << ans;
}
