#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int t;
  t = 1;
  while (t--) {
    int k, r;
    cin >> k >> r;
    int mark = 0;
    for (int i = 1; i < 10; i++) {
      if ((k * i) % 10 == r || (k * i) % 10 == 0) {
        mark = 1;
        cout << i;
        break;
      }
    }
    if (mark == 0) cout << 10;
  }
  return 0;
}
