#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, r, score = 1;
  cin >> n >> r;
  int temp = n;
  while (true) {
    if (temp % 10 == r)
      break;
    else if (temp % 10 == 0)
      break;
    else {
      score += 1;
      temp += n;
    }
  }
  cout << score;
}
