#include <bits/stdc++.h>
int main() {
  int price, coin;
  std::cin >> price >> coin;
  int counter = 1;
  while (1) {
    if (price * counter % 10 == 0 || price * counter % 10 == coin) {
      std::cout << counter << std::endl;
      return 0;
    } else {
      counter++;
    }
  }
  return 0;
}
