#include <bits/stdc++.h>
using namespace std;
const int N = 1234567;
const int mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long a, b;
  cin >> a >> b;
  long long res = 1;
  while (b != a) {
    res = (res % 10 * b % 10) % 10;
    if (res % 10 == 0) break;
    b--;
  }
  cout << res % 10 << endl;
  return 0;
}
