#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;


signed main(){
	cout<<fixed<<setprecision(10);
	
	int A, B;
	vector<int> num;
	vector<vector<int>> dp;
	vector<int> p;
	int ans = 0;
	int n;
	
	cin>>A>>B;
	
	for(int i = 2; i <= B - A; i++){
		bool flag = false;
		
		for(int j = 2; j * j <= i; j++){
			if(i%j == 0) {
				flag = true;
				break;
			}
		}
		
		if(!flag) p.push_back(i);
	}
	
	n = p.size();
	
	num.resize(B - A + 1);
	dp.resize(B - A + 2, vector<int>(1<<n));
	
	for(int i = A; i <= B; i++){
		int bit = 0;
		for(int j = 0; j < n; j++){
			if(i%p[j] == 0) {
				bit |= (1<<j);
				
			}
		}
		num[i-A] = bit;
	}
	
	dp[0][0] = 1;
	
	for(int i = A; i <= B; i++){
		for(int j = 0; j < 1<<n; j++){
			if(!(num[i-A]&j)) dp[i-A+1][num[i-A]|j] += dp[i-A][j];
				dp[i-A+1][j] += dp[i-A][j];
		}
	}
	
	for(int j = 0; j < 1<<n; j++){
		ans += dp[B - A + 1][j];
	}
	
	cout<<ans<<endl;
	
	return 0;
}
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n, t;
ll a[MAXN];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);

    #ifdef Local
        freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/int.txt","r",stdin);
        freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/out.txt","w",stdout);
    #endif

    cin>>n>>t;
  
  	for(int i = 0; i < n; i++)
      	cin>>a[i];
  
  
 	int m = n / 2;
  	vector<int> vc;
  	int ans = 0;
  	for(int i = 0; i < (1<<m); i++){
        ll top = 0;
    	for(int j = 0; j < m; j++){
         	if((1<<j) & i)
              	top += a[j];
        }
      	if(top > t) continue;
        
      	vc.push_back(top);
        ans = max(ans,(int) top);
    }
  
  	sort(vc.begin(), vc.end());
      
	int len = (n - m);
  	
    for(int i = 0; i < (1<<len); i++){
    	ll top = 0;
		for(int j = 0; j < len; j++){
        	if((1<<j) & i)
              top += a[m + j];
        }
      
      	if(top > t) continue;
      	ans = max(ans,(int) top);
      	int ot = upper_bound(vc.begin(), vc.end(), t - top) - vc.begin();
        //cout<<top<<" "<<vc[ot - 1]<<endl;
      	if(ot != 0)
          	ans = max(ans, (int)top + vc[ot - 1]);
    }
  
  
  	cout<<ans<<endl;

    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}