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