// Code Written by Pinaki Bhattacharjee (pinakipb2)
#include<bits/stdc++.h>
using namespace std;

// typedef
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;

// #define
#define LOCAL
#define INF 1e18
#define PI 2*acos(0.0)
#define endl "\n"
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define ppc __builtin_popcountll
#define pinakipb2 ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

// constants
const int MAX = 2e5 + 5;
const int MOD = (int) 1e9 + 7;

ll func(ll a)
{
    ll temp=0;
    while(a)
    {
        temp += (a%10);
        a/=10;
    }
    return temp;
}

int main()
{
    pinakipb2;
    
    ll a,b;
    cin>>a>>b;
    cout<<max(func(a),func(b))<<endl;
    
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 20;
const int M = 73;
const int K[N] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71};
ll a, b, f[M + 1][1 << N];
int s[M], c;
ll help(int i, int j) {
  if (f[i][j]) {
    return f[i][j];
  }
  f[i][j] = 1;
  for (int k = i; k <= b - a; ++k) {
    if (s[k] && (j & s[k]) == 0) {
      f[i][j] += help(k + 1, j | s[k]);
    }
  }
  return f[i][j];
}
int main() {
  cin >> a >> b;
  for (ll i = a; i <= b; ++i) {
    for (int j = 0; j < N; ++j) {
      if (i % K[j] == 0) {
        s[i - a] |= 1 << j;
      }
    }
    c += !s[i - a];
  }
  cout << help(0, 0) * (1 << c);
  return 0;
}