#include <bits/stdc++.h>
#define ll long long
#define el cout << '\n'
using namespace std;
struct BigInt
{
static const int BASE = 16;
static const int B = 1;
vector<ll> a;
BigInt() {};
BigInt(const string &s)
{
int n = s.size();
for (int i = n - 1; i >= 0; i--)
{
if (isdigit(s[i])) a.push_back(s[i] - '0');
else a.push_back(tolower(s[i]) - 'a' + 10);
}
}
void trim()
{
while (a.size() && a.back() == 0)
a.pop_back();
}
BigInt operator-=(const BigInt &other)
{
int n = a.size();
int m = other.a.size();
int carry = 0;
for (int i = 0; i < m || carry; i++)
{
a[i] -= (i < m ? other.a[i] : 0) + carry;
if (a[i] < 0)
{
a[i] += BASE;
carry = 1;
}
else carry = 0;
}
trim();
return (*this);
}
BigInt operator-(const BigInt &other)
{
return BigInt(*this) -= other;
}
bool operator>(const int &d)
{
if (a.size() == 0) return 0;
if (a.size() >= 2) return 1;
return a.back() > d;
}
ll operator%(const int &m)
{
int n = a.size();
int carry = 0;
for (int i = n - 1; i >= 0; i--)
carry = (a[i] + carry * BASE) % m;
return carry;
}
friend istream& operator>>(istream &inp, BigInt &a)
{
string s;
inp >> s;
a = BigInt(s);
return inp;
}
};
BigInt a, b;
ll toInt(BigInt a)
{
ll ans = 0;
int n = a.a.size();
for (int i = n - 1; i >= 0; i--)
ans = a.BASE * ans + a.a[i];
return ans;
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if (fopen("BBDS.INP", "r"))
{
freopen("BBDS.INP", "r", stdin);
freopen("BBDS.OUT", "w", stdout);
}
cin >> a >> b;
if (b - a > 4) return cout << "F", 0;
int m = a % 15;
int ans = m;
int dis = toInt(b - a);
for (int i = 1; i <= dis; i++)
ans *= ++m;
ans %= 15;
if (ans == 0) ans = 15;
if (ans >= 10) cout << (char)('A' + ans - 10);
else cout << ans;
}