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