#include<bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;
typedef long long int lli;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair<int,int> pii;
typedef pair<long long int,long long int> plli;
typedef vector< vi > vvi ;
typedef vector< vlli > vvlli  ;
#define fi(i,a,b) for(int i=a;i<=b;i++)
#define flli(i,a,b) for(long long int i=a;i<=b;i++)
#define bi(i,a,b) for(int i=a;i>=b;i--)
#define blli(i,a,b) for(long long int i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pi 2*acos(0.0)
#define pb push_back
#define tr(v,it) for(decltype(v.begin()) it=v.begin();it!=v.end();it++)
#define present(v,num) (v.find(num)!=v.end())
#define cpresent(v,num) (find(v.begin(),v.end(),num)!=v.end())
#define pq priority_queue
#define mp make_pair
const int inf=INT_MAX;
const lli INF =LLONG_MAX;
const lli mod = 1e9+7;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fast;
    lli n,m;cin>>n>>m;
    vlli count(1001,0);
    flli(i,0,n-1)
    {
    	lli temp;cin>>temp;
    	count[temp]++;
    }
    flli(i,0,m-1)
    {
    	lli temp;cin>>temp;
    	count[temp]++;
    }
    flli(i,0,1000)
    {
    	if(count[i]==1)
    	{
    		cout<<i<<" ";
    	}
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector> 
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define fi first
#define se second
const int N=2010;
int n,m,k,a[N];
ll f[1<<21][2];

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i) scanf("%d",a+i);
	k=n/2;
	for(int i=0;i<(1<<k);++i)
	{
		for(int j=0;j<k;++j)
			if(((i>>j)&1)==0)
				f[i+(1<<j)][0]=f[i][0]+a[j+1];
	}
	int x=n-k;
	for(int i=0;i<(1<<x);++i)
	{
		for(int j=0;j<x;++j)
			if(((i>>j)&1)==0)
				f[i+(1<<j)][1]=f[i][1]+a[j+1+k];
	}
	vector<ll> nums1,nums2;
	for(int i=0;i<(1<<x);++i)
	{
		if(i<(1<<k)&&f[i][0]<=m) nums1.push_back(f[i][0]);
		if(f[i][1]<=m) nums2.push_back(f[i][1]);
	}
	sort(nums1.begin(),nums1.end());
	nums1.erase(unique(nums1.begin(),nums1.end()),nums1.end());
	sort(nums2.begin(),nums2.end());
	nums2.erase(unique(nums2.begin(),nums2.end()),nums2.end());
	ll ans=0;
	for(int i=0;i<nums1.size();++i)
	{
		int pos=lower_bound(nums2.begin(),nums2.end(),m+1-nums1[i])-nums2.begin();
		if(pos==nums2.size()) ans=max(nums1[i]+nums2[nums2.size()-1],ans);
		else if(pos>0) ans=max(ans,nums2[pos-1]+nums1[i]);
		//cout<<nums1[i]<<' ';
	}
	//cout<<endl;

	for(int i=0;i<nums2.size();++i)
	{
		int pos=lower_bound(nums1.begin(),nums1.end(),m+1-nums2[i])-nums1.begin();
		if(pos==nums1.size()) ans=max(nums2[i]+nums1[nums1.size()-1],ans);
		else if(pos>0) ans=max(ans,nums1[pos-1]+nums2[i]);
		//cout<<nums2[i]<<' ';
	}
	//cout<<endl;
	printf("%lld",ans);
	return 0;
}