#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int i = 1;
  for (int j = 1; j <= 6;) {
    if (n * i % 10 == 0 || (n * i - m) % 10 == 0) {
      cout << i;
      return 0;
    }
    i++;
  }
  return 0;
}
