#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const ll N=18;
ll g[20][20];
ll dp[1<<N],dp1[1<<N],power[N];
vector<ll> arr[20];


ll fun1(vector<ll> &nodes){
      if(nodes.size()==0) return(0);
      ll flag=1;
      for(auto u:nodes){
            for(auto v:nodes){
                  if(u+1==v+1) continue;
                  if(g[u+1][v+1]==0){
                        flag=0;
                        break;
                  }
            }
            if(flag==0) break;
      }
      //for(auto x:nodes) cout<<x+1<<" ";
      //cout<<flag;
      //cout<<endl;
      return(flag);
}

void fun2(ll num,ll n){
      vector<ll> nodes;
      forn(i,n){
            if((num&(1<<i))!=0) nodes.pb(i);
      }
      dp1[num]=fun1(nodes);
}


void fun(ll n,ll num){

      for(ll i=num;i>0;i=((i-1)&num)){
            ll num2=i;
            ll num1=num2^num;
            if(dp1[num2]==0) continue;
            else dp[num]=min(dp1[num2]+dp[num1],dp[num]);
      }  

}

int main(){
      sync
      ll n,m;
      cin>>n>>m;

      power[0]=1;
      for1(i,n) power[i]=2*power[i-1];

      forn(i,m){
            ll u,v;
            cin>>u>>v;
            g[u][v]=1;
            g[v][u]=1;
      }

      forn(i,1<<n){
            ll c=0,num=0,p=1;
            forn(j,n){
                  if((i&(1<<j))!=0){
                        num=num+p;
                        c++;
                  }
                  p*=2;
            }
            dp[num]=c;
            arr[c].pb(num);
            fun2(i,n);
      }

      dp[0]=0;

      forn(i,n+1){
            for(auto x:arr[i]){
                  fun(n,x);
            }
      }
      //forn(i,1<<n) cout<<dp[i]<<" ";
      cout<<dp[(1<<n)-1];
}
#define _USE_MATH_DEFINES

#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <queue>

#define	INF   1010101010
#define INFLL 1010101010101010101

using namespace std;

int mod = 1000000007;

int main()
{
	int n;
	long long t;
	cin >> n >> t;
	vector<long long> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	vector<long long> b;
	int n2 = n / 2;
	int n3 = n - n2;
	for (int i = 0; i < (1 << n2); i++) {
		long long sum = 0;
		for (int j = 0; j < n2; j++) {
			if (((i >> j) & 1) == 1) {
				sum += a[j];
			}
		}
		if (sum <= t) {
			b.emplace_back(sum);
		}
	}
	sort(b.begin(), b.end());
	long long ans = 0;
	for (int i = 0; i < (1 << n3); i++) {
		long long sum = 0;
		for (int j = n / 2; j < n; j++) {
			if (((i >> (j - n / 2)) & 1) == 1) {
				sum += a[j];
			}
		}
		if (sum > t) continue;
		int u = upper_bound(b.begin(), b.end(), t - sum) - b.begin();
		u--;
		ans = max(ans, b[u] + sum);
	}
	cout << ans << endl;

	return 0;
}