#include <bits/stdc++.h>
using namespace std;
int main() {
  int price = 0, change = 0;
  cin >> price >> change;
  int count = 1;
  int temp = price;
  while (!((price % 10) == 0 || (price % 10) == change)) {
    count++;
    price = temp * count;
  }
  cout << count << "\n";
}
