/*
Author: 1412kid1412@UESTC
*/

#include <stdexcept>
#include <cstdarg>
#include <iostream>
#include <fstream>
#include <exception>
#include <memory>
#include <locale>
#include <sstream>
#include <set>
#include <list>
#include <bitset>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <string>
#include <utility>
#include <cctype>
#include <climits>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <map>
#include <cmath>
#include <algorithm>
#include <ctime>
#include <vector>
#include <queue>
#include <deque>
#include <cstdlib>
#include <stack>
#include <iterator>
#include <functional>
#include <complex>
#include <valarray>
using namespace std;

int a[2010],s[2010];
int dp[2010][4010];
const int mod=1000000007;

int main(){
    int n,k;
    scanf("%d%d",&n,&k);

    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        a[i]>>=1;
    }
    for(int i=n-1;i>=0;i--){
        s[i]=s[i+1]+(s[i]==0);
    }
    k--;

    int ret=0;
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<(1<<k);j++){
            if(!dp[i][j]){
                continue;
            }
            if(a[j]==1||a[j]==0){
                dp[i+1][j+1]+=dp[i][j];
                dp[i+1][j+1]%=mod;
            }
            if(a[j]==2||a[j]==0){
                if(j&1){
                    dp[i+1][2]+=dp[i][j];
                    dp[i+1][2]%=mod;
                }
                else{
                    dp[i+1][j+2]+=dp[i][j];
                    dp[i+1][j+2]%=mod;
                }
            }
        }
        for(int j=(1<<k);j<=4000;j++){
            ret+=(1LL<<s[i+1])%mod*dp[i+1][j]%mod;
            ret%=mod;
        }
    }
    printf("%d\n",ret);

    return 0;
}


/*
Author: 1412kid1412@UESTC
*/

#include <stdexcept>
#include <cstdarg>
#include <iostream>
#include <fstream>
#include <exception>
#include <memory>
#include <locale>
#include <sstream>
#include <set>
#include <list>
#include <bitset>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <string>
#include <utility>
#include <cctype>
#include <climits>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <map>
#include <cmath>
#include <algorithm>
#include <ctime>
#include <vector>
#include <queue>
#include <deque>
#include <cstdlib>
#include <stack>
#include <iterator>
#include <functional>
#include <complex>
#include <valarray>
using namespace std;

int a[2010],s[2010];
int dp[2010][4010];
const int mod=1000000007;

int main(){
    int n,k;
    scanf("%d%d",&n,&k);

    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        a[i]>>=1;
    }
    for(int i=n-1;i>=0;i--){
        s[i]=s[i+1]+(s[i]==0);
    }
    k--;

    int ret=0;
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<(1<<k);j++){
            if(!dp[i][j]){
                continue;
            }
            if(a[i]==1||a[i]==0){
                dp[i+1][j+1]+=dp[i][j];
                dp[i+1][j+1]%=mod;
            }
            if(a[i]==2||a[i]==0){
                if(j&1){
                    dp[i+1][2]+=dp[i][j];
                    dp[i+1][2]%=mod;
                }
                else{
                    dp[i+1][j+2]+=dp[i][j];
                    dp[i+1][j+2]%=mod;
                }
            }
        }
        for(int j=(1<<k);j<=4000;j++){
            if(!dp[i+1][j]){
                continue;
            }
            ret+=(1LL<<s[i+1])%mod*dp[i+1][j]%mod;
            ret%=mod;
        }
    }
    printf("%d\n",ret);

    return 0;
}


/*
Author: 1412kid1412@UESTC
*/

#include <stdexcept>
#include <cstdarg>
#include <iostream>
#include <fstream>
#include <exception>
#include <memory>
#include <locale>
#include <sstream>
#include <set>
#include <list>
#include <bitset>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <string>
#include <utility>
#include <cctype>
#include <climits>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <map>
#include <cmath>
#include <algorithm>
#include <ctime>
#include <vector>
#include <queue>
#include <deque>
#include <cstdlib>
#include <stack>
#include <iterator>
#include <functional>
#include <complex>
#include <valarray>
using namespace std;

int a[2010],s[2010];
int dp[2010][4010];
const int mod=1000000007;

int main(){
    int n,k;
    scanf("%d%d",&n,&k);

    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        a[i]>>=1;
    }
    for(int i=n-1;i>=0;i--){
        s[i]=s[i+1]+(s[i]==0);
    }
    k--;

    int ret=0;
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<(1<<k);j++){
            if(!dp[i][j]){
                continue;
            }
            if(a[i]==1||a[i]==0){
                dp[i+1][j+1]+=dp[i][j];
                dp[i+1][j+1]%=mod;
            }
            if(a[i]==2||a[i]==0){
                if(j&1){
                    dp[i+1][2]+=dp[i][j];
                    dp[i+1][2]%=mod;
                }
                else{
                    dp[i+1][j+2]+=dp[i][j];
                    dp[i+1][j+2]%=mod;
                }
            }
        }
        for(int j=(1<<k);j<=4000;j++){
            if(!dp[i+1][j]){
                continue;
            }
            printf("%d %d %d\n",i+1,j,dp[i+1][j]);
            ret+=(1LL<<s[i+1])%mod*dp[i+1][j]%mod;
            ret%=mod;
        }
    }
    printf("%d\n",ret);

    return 0;
}


#include <iostream>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <set>
#include <map>
#include <algorithm>

#define file_name "test"

using namespace std;

const int N = 2e3+3;
const int M = (1<<11);
const int mod = 1e9 + 7;

int a[N], d[M], b[M];
int m, k;
void make(int c)
{
    int i;
    c >>= 1;
    for(i=0; i<m; ++i)
        if(i&(1<<(k-1)))
            b[i] = (b[i]+d[i])%mod;
        else
        {
            if((c==2)&&(i&1))
                b[2] = (b[2]+d[i])%mod;
            else
            {
                //if(d[i])
               //     printf("%d %d i=%d c=%d i+c=%d\n", b[i+c], d[i], i, c, i+c);
                b[i+c] = (b[i+c]+d[i])%mod;
            }
        }
}

int main()
{
    //freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//    freopen(file_name".in", "r", stdin); freopen(file_name".out", "w", stdout);

    int i, j, n, ans;
    scanf("%d%d", &n, &k);
    for(i=0; i<n; ++i)
        scanf("%d", &a[i]);

    m = 1<<k;
    for(i=0; i<m; ++i)
        d[i] = 0;

    d[0] = 1;
    ans = 0;
    for(i=0; i<n; ++i)
    {
        for(j=0; j<m; ++j)
            b[j] = 0;
        if(a[i])
            make(a[i]);
        else
        {
            make(2);
            make(4);
        }
        for(j=0; j<m; ++j)
            d[j] = b[j];

        /*printf("i=%d\n", i);
        for(j=0; j<m; ++j)
            if(d[j])
            {
                printf("d[j]=%d j=%d\n", d[j], j);
            }*/
    }
    ans = 0;
    for(i=0; i<m; ++i)
        if(i&(1<<(k-1)))
            ans = (ans+d[i])%mod;

    printf("%d\n", ans);
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <set>
#include <map>
#include <algorithm>

#define file_name "test"

using namespace std;

const int N = 2e3+3;
const int M = (1<<11);
const int mod = 1e9 + 7;

int a[N], d[M], b[M];
int m, k;
void make(int c)
{
    int i;
    c >>= 1;
    for(i=0; i<m; ++i)
        if(i&(1<<(k-1)))
            b[i] += d[i];
        else
        {
            if((c==2)&&(i&1))
                b[2] += d[i];
            else
            {
                //if(d[i])
               //     printf("%d %d i=%d c=%d i+c=%d\n", b[i+c], d[i], i, c, i+c);
                b[i+c] += d[i];
            }
        }
}

int main()
{
    //freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//    freopen(file_name".in", "r", stdin); freopen(file_name".out", "w", stdout);

    int i, j, n, ans;
    scanf("%d%d", &n, &k);
    for(i=0; i<n; ++i)
        scanf("%d", &a[i]);

    m = 1<<k;
    for(i=0; i<m; ++i)
        d[i] = 0;

    d[0] = 1;
    ans = 0;
    for(i=0; i<n; ++i)
    {
        for(j=0; j<m; ++j)
            b[j] = 0;
        if(a[i])
            make(a[i]);
        else
        {
            make(2);
            make(4);
        }
        for(j=0; j<m; ++j)
            d[j] = b[j];

        /*printf("i=%d\n", i);
        for(j=0; j<m; ++j)
            if(d[j])
            {
                printf("d[j]=%d j=%d\n", d[j], j);
            }*/
    }
    ans = 0;
    for(i=0; i<m; ++i)
        if(i&(1<<(k-1)))
            ans = (ans+d[i])%mod;

    printf("%d\n", ans);
    return 0;
}


/*
it's only after we've lost everything that we're free to do anything
-tyler durden
*/
#include <bits/stdc++.h>

using namespace std;

const int maxl = 1 << 12;
const int maxn = 2 * 1000 + 5;
const int mod = 1000 * 1000 * 1000 + 7;

int dp [ maxl ][ maxn ];
int n, k;

int ans;

inline int add_2 ( int mask ){
	mask++;

	return ( mask >= maxl ? -1 : mask );
}

inline int add_4 ( int mask ){
	if ( mask & 1 )
		return 2;

	mask += 2;
	return ( mask >= maxl ? -1 : mask );
}

inline void add ( int ind, int mask, int x ){
	int msk = -1;
	if ( x == 2 || x == 0 )
		msk = add_2 ( mask );

	if ( msk + 1 ){
		dp [ msk ][ ind + 1 ] += dp [ mask ][ ind ];
		dp [ msk ][ ind + 1 ] %= mod;
	}
	msk = -1;

	if ( x == 4 || x == 0 )
		msk = add_4 ( mask );

	if ( msk + 1 ){
		dp [ msk ][ ind + 1 ] += dp [ mask ][ ind ];
		dp [ msk ][ ind + 1 ] %= mod;
	}
}

void print ( int x, int i ){
	if ( i == 0 )
		return;

	print ( x >> 1, i - 1 );
	cout << (x & 1);
}

int main (){
	cin >> n >> k;

	dp [ 0 ][ 0 ] = 1;
	k--;

	for ( int i = 0 ; i < n ; i++ ){
		int x;
		cin >> x;

		for ( int mask = 0 ; mask < maxl ; mask++ )
			add ( i, mask, x );
	}

	for ( int mask = 1 << k ; mask < maxl ; mask++ )
		ans += dp [ mask ][ n ],
		ans %= mod;

	cout << ans << endl;
}


/*
it's only after we've lost everything that we're free to do anything
-tyler durden
*/
#include <bits/stdc++.h>

using namespace std;

const int maxl = 1 << 12;
const int maxn = 2 * 1000 + 5;
const int mod = 1000 * 1000 * 1000 + 7;

int dp [ maxl ][ maxn ];
int n, k;

int ans;

inline int add_2 ( int mask ){
	mask++;

	return ( mask >= maxl ? -1 : mask );
}

inline int add_4 ( int mask ){
	if ( mask & 1 )
		return (maxl >> 1) * (mask >= (1 << k)) + 2;

	mask += 2;
	return ( mask >= maxl ? -1 : mask );
}

inline void add ( int ind, int mask, int x ){
	int msk = -1;
	if ( x == 2 || x == 0 )
		msk = add_2 ( mask );

	if ( msk + 1 ){
		dp [ msk ][ ind + 1 ] += dp [ mask ][ ind ];
		dp [ msk ][ ind + 1 ] %= mod;
	}
	msk = -1;

	if ( x == 4 || x == 0 )
		msk = add_4 ( mask );

	if ( msk + 1 ){
		dp [ msk ][ ind + 1 ] += dp [ mask ][ ind ];
		dp [ msk ][ ind + 1 ] %= mod;
	}
}

void print ( int x, int i ){
	if ( i == 0 )
		return;

	print ( x >> 1, i - 1 );
	cout << (x & 1);
}

int main (){
	cin >> n >> k;

	dp [ 0 ][ 0 ] = 1;
	k--;

	for ( int i = 0 ; i < n ; i++ ){
		int x;
		cin >> x;

//		cout << "i = " << i << " {\n";
		for ( int mask = 0 ; mask < maxl ; mask++ ){
//			cout << "    ";
//			print ( mask, 5 );
//			cout << " --> " << dp [ mask ][ i ] << '\n';

			add ( i, mask, x );
		}
//		cout << "}\n";
	}

/*
5 3
4 4 0 0 0
*/

	for ( int mask = 1 << k ; mask < maxl ; mask++ )
		ans += dp [ mask ][ n ],
		ans %= mod;

	cout << ans << endl;
}


/*
it's only after we've lost everything that we're free to do anything
-tyler durden
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

const int maxl = 1 << 12;
const int maxn = 2 * 1000 + 5;
const ll mod = 1000 * 1000 * 1000 + 7;

ll dp [ maxl ][ maxn ];
int n, k;

ll ans;

inline int add_2 ( int mask ){
	mask++;

	return ( mask >= maxl ? -1 : mask );
}

inline int add_4 ( int mask ){
	if ( mask & 1 )
		return (maxl >> 1) * (mask >= (1 << k)) + 2;

	mask += 2;
	return ( mask >= maxl ? -1 : mask );
}

inline void add ( int ind, int mask, int x ){
	int msk = -1;
	if ( x == 2 || x == 0 )
		msk = add_2 ( mask );

	if ( msk + 1 ){
		dp [ msk ][ ind + 1 ] += dp [ mask ][ ind ];
		dp [ msk ][ ind + 1 ] %= mod;
	}
	msk = -1;

	if ( x == 4 || x == 0 )
		msk = add_4 ( mask );

	if ( msk + 1 ){
		dp [ msk ][ ind + 1 ] += dp [ mask ][ ind ];
		dp [ msk ][ ind + 1 ] %= mod;
	}
}

void print ( int x, int i ){
	if ( i == 0 )
		return;

	print ( x >> 1, i - 1 );
	cout << (x & 1);
}

int main (){
	cin >> n >> k;

	dp [ 0 ][ 0 ] = 1;
	k--;

	for ( int i = 0 ; i < n ; i++ ){
		int x;
		cin >> x;

//		cout << "i = " << i << " {\n";
		for ( int mask = 0 ; mask < maxl ; mask++ ){
//			cout << "    ";
//			print ( mask, 5 );
//			cout << " --> " << dp [ mask ][ i ] << '\n';

			add ( i, mask, x );
		}
//		cout << "}\n";
	}

/*
5 3
4 4 0 0 0
*/

	for ( int mask = 1 << k ; mask < maxl ; mask++ )
		ans += dp [ mask ][ n ],
		ans %= mod;

	cout << ans << endl;
}


/*
it's only after we've lost everything that we're free to do anything
-tyler durden
*/
#include <bits/stdc++.h>

using namespace std;

const int maxl = 1 << 12;
const int maxn = 2 * 1000 + 5;
const int mod = 1000 * 1000 * 1000 + 7;

int dp [ maxl ][ maxn ];
int n, k;

int ans;

inline int add_2 ( int mask ){
	mask++;

	return ( mask >= maxl ? -1 : mask );
}

inline int add_4 ( int mask ){
	if ( mask & 1 )
		return (maxl >> 1) + 2;

	mask += 2;
	return ( mask >= maxl ? -1 : mask );
}

inline void add ( int ind, int mask, int x ){
	int msk = -1;
	if ( x == 2 || x == 0 )
		msk = add_2 ( mask );

	if ( msk + 1 ){
		dp [ msk ][ ind + 1 ] += dp [ mask ][ ind ];
		dp [ msk ][ ind + 1 ] %= mod;
	}
	msk = -1;

	if ( x == 4 || x == 0 )
		msk = add_4 ( mask );

	if ( msk + 1 ){
		dp [ msk ][ ind + 1 ] += dp [ mask ][ ind ];
		dp [ msk ][ ind + 1 ] %= mod;
	}
}

void print ( int x, int i ){
	if ( i == 0 )
		return;

	print ( x >> 1, i - 1 );
	cout << (x & 1);
}

int main (){
	cin >> n >> k;

	dp [ 0 ][ 0 ] = 1;
	k--;

	for ( int i = 0 ; i < n ; i++ ){
		int x;
		cin >> x;

//		cout << "i = " << i << " {\n";
		for ( int mask = 0 ; mask < maxl ; mask++ ){
//			cout << "    ";
//			print ( mask, 5 );
//			cout << " --> " << dp [ mask ][ i ] << '\n';

			add ( i, mask, x );
		}
//		cout << "}\n";
	}

/*
5 3
4 4 0 0 0
*/

	for ( int mask = 1 << k ; mask < maxl ; mask++ )
		ans += dp [ mask ][ n ],
		ans %= mod;

	cout << ans << endl;
}


/*
it's only after we've lost everything that we're free to do anything
-tyler durden
*/
#include <bits/stdc++.h>

using namespace std;

const int maxl = 1 << 5;
const int maxn = 2 * 1000 + 5;
const int mod = 1000 * 1000 * 1000 + 7;

int dp [ maxl ][ maxn ];
int n, k;

int ans;

inline int add_2 ( int mask ){
	mask++;

	return ( mask >= maxl ? -1 : mask );
}

inline int add_4 ( int mask ){
	if ( mask & 1 )
		return 2;

	mask += 2;
	return ( mask >= maxl ? -1 : mask );
}

inline void add ( int ind, int mask, int x ){
	int msk = -1;
	if ( x == 2 || x == 0 )
		msk = add_2 ( mask );

	if ( msk + 1 ){
		dp [ msk ][ ind + 1 ] += dp [ mask ][ ind ];
		dp [ msk ][ ind + 1 ] %= mod;
	}
	msk = -1;

	if ( x == 4 || x == 0 )
		msk = add_4 ( mask );

	if ( msk + 1 ){
		dp [ msk ][ ind + 1 ] += dp [ mask ][ ind ];
		dp [ msk ][ ind + 1 ] %= mod;
	}
}

void print ( int x, int i ){
	if ( i == 0 )
		return;

	print ( x >> 1, i - 1 );
	cout << (x & 1);
}

int main (){
	cin >> n >> k;

	dp [ 0 ][ 0 ] = 1;
	k--;

	for ( int i = 0 ; i < n ; i++ ){
		int x;
		cin >> x;

		for ( int mask = 0 ; mask < maxl ; mask++ )
			add ( i, mask, x );
	}

	for ( int mask = 1 << k ; mask < maxl ; mask++ )
		ans += dp [ mask ][ n ],
		ans %= mod;

	cout << ans << endl;
}


/*
it's only after we've lost everything that we're free to do anything
-tyler durden
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

const int maxl = 1 << 13;
const int maxn = 2 * 1000 + 5;
const ll mod = 1000 * 1000 * 1000 + 7;

ll dp [ maxl ][ maxn ];
int n, k;

ll ans;

inline int add_2 ( int mask ){
	mask++;

	return ( mask >= maxl ? -1 : mask );
}

inline int add_4 ( int mask ){
	if ( mask & 1 )
		return (maxl >> 1) * (mask >= (1 << k)) + 2;

	mask += 2;
	return ( mask >= maxl ? -1 : mask );
}

inline void add ( int ind, int mask, int x ){
	int msk = -1;
	if ( x == 2 || x == 0 )
		msk = add_2 ( mask );

	if ( msk + 1 ){
		dp [ msk ][ ind + 1 ] += dp [ mask ][ ind ];
		dp [ msk ][ ind + 1 ] %= mod;
	}
	msk = -1;

	if ( x == 4 || x == 0 )
		msk = add_4 ( mask );

	if ( msk + 1 ){
		dp [ msk ][ ind + 1 ] += dp [ mask ][ ind ];
		dp [ msk ][ ind + 1 ] %= mod;
	}
}

void print ( int x, int i ){
	if ( i == 0 )
		return;

	print ( x >> 1, i - 1 );
	cout << (x & 1);
}

int main (){
	cin >> n >> k;

	dp [ 0 ][ 0 ] = 1;
	k--;

	for ( int i = 0 ; i < n ; i++ ){
		int x;
		cin >> x;

//		cout << "i = " << i << " {\n";
		for ( int mask = 0 ; mask < maxl ; mask++ ){
//			cout << "    ";
//			print ( mask, 5 );
//			cout << " --> " << dp [ mask ][ i ] << '\n';

			add ( i, mask, x );
		}
//		cout << "}\n";
	}

/*
5 3
4 4 0 0 0
*/

	for ( int mask = 1 << k ; mask < maxl ; mask++ )
		ans += dp [ mask ][ n ],
		ans %= mod;

	cout << ans << endl;
}


#include<bits/stdc++.h>

using namespace std;

#define pii pair<int,int>
#define ll long long
#define N (int)(1e5+10)
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define nd second
#define st first
#define inf mod
#define endl '\n'
#define sag (sol|1)
#define sol (root<<1)
#define ort ((bas+son)>>1)
#define bit(x,y) ((x>>y)&1)

int dp[2004][(1<<12)+4][2];
int i,j,k,n,m,x,y,z,arr[N];

int f(int x,int mask,int w){

	if(bit(mask,k))
		w=1;

	int &r = dp[x][mask][w];

	if(w)
		mask=0;

	if(x == n+1)
		return w;

	if(r != -1)
		return r;

	if(arr[x]==2)
		return r = f(x+1,mask+2,w);
	if(arr[x]==4){
		if(bit(mask,1))
			return r = f(x+1,4,w);
		return r = f(x+1,mask+4,w);
	}
	r = f(x+1,mask+2,w);

	if(bit(mask,1))
		return r = (r + f(x+1,4,w))%mod;

	return r = (r + f(x+1,mask+4,w))%mod;
}

int main(){
	memset(dp,-1,sizeof dp);

	cin >> n >> k;

	for(i=1 ; i<=n ; i++)
		scanf("%d",arr+i);

	cout << f(1,0,0) << endl;
}


#include<bits/stdc++.h>

using namespace std;

#define pii pair<int,int>
#define ll long long
#define N (int)(1e5+10)
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define nd second
#define st first
#define inf mod
#define endl '\n'
#define sag (sol|1)
#define sol (root<<1)
#define ort ((bas+son)>>1)
#define bit(x,y) ((x>>y)&1)

int dp[2004][1<<12+4];
int i,j,k,n,m,x,y,z,arr[N];

int f(int x,int mask){

	if(bit(mask,k))
		return 1;

	int &r = dp[x][mask];

	if(x == n+1)
		return 0;

	if(r != -1)
		return r;

	if(arr[x]==2)
		return r = f(x+1,mask+2);
	if(arr[x]==4){
		if(bit(mask,1))
			return r = f(x+1,4);
		return r = f(x+1,mask+4);
	}
	r = f(x+1,mask+2);

	if(bit(mask,1))
		return r = (r + f(x+1,4))%mod;

	return r = (r + f(x+1,mask+4))%mod;
}

int main(){
	memset(dp,-1,sizeof dp);

	cin >> n >> k;

	for(i=1 ; i<=n ; i++)
		scanf("%d",arr+i);

	cout << f(1,0) << endl;
}


#include<bits/stdc++.h>

using namespace std;

#define pii pair<int,int>
#define ll long long
#define N (int)(1e5+10)
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define nd second
#define st first
#define inf mod
#define endl '\n'
#define sag (sol|1)
#define sol (root<<1)
#define ort ((bas+son)>>1)
#define bit(x,y) ((x>>y)&1)

int dp[2004][(1<<12)+4][2];
int i,j,k,n,m,x,y,z,arr[N];

int f(int x,int mask,int w){

	if(bit(mask,k))
		w=1;

	int &r = dp[x][mask][w];

	if(x == n+1)
		return w;

	if(r != -1)
		return r;

	if(arr[x]==2)
		return r = f(x+1,mask+2,w);
	if(arr[x]==4){
		if(bit(mask,1))
			return r = f(x+1,4,w);
		return r = f(x+1,mask+4,w);
	}
	r = f(x+1,mask+2,w);

	if(bit(mask,1))
		return r = (r + f(x+1,4,w))%mod;

	return r = (r + f(x+1,mask+4,w))%mod;
}

int main(){
	memset(dp,-1,sizeof dp);

	cin >> n >> k;

	for(i=1 ; i<=n ; i++)
		scanf("%d",arr+i);

	cout << f(1,0,0) << endl;
}


#include<bits/stdc++.h>

using namespace std;

#define pii pair<int,int>
#define ll long long
#define N (int)(1e5+10)
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define nd second
#define st first
#define inf mod
#define endl '\n'
#define sag (sol|1)
#define sol (root<<1)
#define ort ((bas+son)>>1)
#define bit(x,y) ((x>>y)&1)

int dp[2004][(1<<12)+4];
int i,j,k,n,m,x,y,z,arr[N];

int f(int x,int mask){

	if(bit(mask,k))
		return 1;

	int &r = dp[x][mask];

	if(x == n+1)
		return 0;

	if(r != -1)
		return r;

	if(arr[x]==2)
		return r = f(x+1,mask+2);
	if(arr[x]==4){
		if(bit(mask,1))
			return r = f(x+1,4);
		return r = f(x+1,mask+4);
	}
	r = f(x+1,mask+2);

	if(bit(mask,1))
		return r = (r + f(x+1,4))%mod;

	return r = (r + f(x+1,mask+4))%mod;
}

int main(){
	memset(dp,-1,sizeof dp);

	cin >> n >> k;

	for(i=1 ; i<=n ; i++)
		scanf("%d",arr+i);

	cout << f(1,0) << endl;
}


/*******************\
|* # By longbiau # *|
\*******************/

#define _CRT_SECURE_NO_WARNINGS

// #include C {
#include<cstring>
#include<cassert>
#include<cstdio>
#include<cctype>
#include<cmath>
// }

// #include C++ {
#include<functional>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<map>
#include<set>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef unsigned long long uint64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
typedef pair <char, char> PCC;
typedef pair <double, double> PDD;
// }
#ifndef ONLINE_JUDGE
// #parameter{
#define TYPE decltype
/////////////////////////////////////////////////////////////
#else
/////////////////////////////////////////////////////////////
#define TYPE __typeof
// }
#endif
// #define {
#define MP make_pair
#define PB push_back
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = 2.0*acos(0.0);
const double EPS = 1e-6;

#define GREATER(x, y) ((x) > (y) + EPS)
#define GREATER_EQUAL(x, y) ((x) > (y) - EPS)
#define LESS(x, y) ((x) < (y) - EPS)
#define LESS_EQUAL(x, y) ((x) < (y) + EPS)
#define EQUAL(x, y) (abs((x) - (y)) < EPS)

#define MAX_N 2005
#define MAXX 0x3f
#define UPPER 2147483647LL
#define INT_MAX 2147483647
#define INF (1<<29)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////
#define MOD 100000007
#define BOUND 2050
int dp[MAX_N][BOUND][2];
void MYADD(int &x, int val){
    x += val;
    if (x >= MOD)
        x -= MOD;
}
/////////////////////////////////////////////////////////////
int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif

    int n, k;
    scanf("%d %d", &n, &k);
    int TARGET = 1 << k;
    dp[0][0][0] = 1;
    for (int i = 1; i <= n; i++){
        int a;
        scanf("%d", &a);
        for (int s = 0; s <= BOUND; s++){
            if (a != 2){
                int t = min(s + 4, TARGET);
                if (s & 2){
                    if (s >= TARGET)
                        MYADD(dp[i][4][1], dp[i - 1][s][0]);
                    else
                        MYADD(dp[i][4][0], dp[i - 1][s][0]);
                    MYADD(dp[i][4][1], dp[i - 1][s][1]);
                }
                else{
                    MYADD(dp[i][t][0], dp[i - 1][s][0]);
                    MYADD(dp[i][t][1], dp[i - 1][s][1]);
                }
            }
            if (a != 4){
                int t = min(s + 2, TARGET);
                MYADD(dp[i][t][0], dp[i - 1][s][0]);
                MYADD(dp[i][t][1], dp[i - 1][s][1]);
            }
        }
    }
    int res = 0;
    for (int s = 0; s <= BOUND; s++){
        MYADD(res, dp[n][s][1]);
        if (s >= TARGET)
            MYADD(res, dp[n][s][0]);
    }
    printf("%d\n", res);
    return 0;
}


/*******************\
|* # By longbiau # *|
\*******************/

#define _CRT_SECURE_NO_WARNINGS

// #include C {
#include<cstring>
#include<cassert>
#include<cstdio>
#include<cctype>
#include<cmath>
// }

// #include C++ {
#include<functional>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<map>
#include<set>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef unsigned long long uint64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
typedef pair <char, char> PCC;
typedef pair <double, double> PDD;
// }
#ifndef ONLINE_JUDGE
// #parameter{
#define TYPE decltype
/////////////////////////////////////////////////////////////
#else
/////////////////////////////////////////////////////////////
#define TYPE __typeof
// }
#endif
// #define {
#define MP make_pair
#define PB push_back
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = 2.0*acos(0.0);
const double EPS = 1e-6;

#define GREATER(x, y) ((x) > (y) + EPS)
#define GREATER_EQUAL(x, y) ((x) > (y) - EPS)
#define LESS(x, y) ((x) < (y) - EPS)
#define LESS_EQUAL(x, y) ((x) < (y) + EPS)
#define EQUAL(x, y) (abs((x) - (y)) < EPS)

#define MAX_N 2005
#define MAXX 0x3f
#define UPPER 2147483647LL
#define INT_MAX 2147483647
#define INF (1<<29)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////
#define MOD 1000000007
#define BOUND 2050
int dp[MAX_N][BOUND][2];
void MYADD(int &x, int val){
    x += val;
    if (x >= MOD)
        x -= MOD;
}
/////////////////////////////////////////////////////////////
int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif

    int n, k;
    scanf("%d %d", &n, &k);
    int TARGET = 1 << k;
    dp[0][0][0] = 1;
    for (int i = 1; i <= n; i++){
        int a;
        scanf("%d", &a);
        for (int s = 0; s <= BOUND; s++){
            if (a != 2){
                int t = min(s + 4, TARGET);
                if (s & 2){
                    if (s >= TARGET)
                        MYADD(dp[i][4][1], dp[i - 1][s][0]);
                    else
                        MYADD(dp[i][4][0], dp[i - 1][s][0]);
                    MYADD(dp[i][4][1], dp[i - 1][s][1]);
                }
                else{
                    MYADD(dp[i][t][0], dp[i - 1][s][0]);
                    MYADD(dp[i][t][1], dp[i - 1][s][1]);
                }
            }
            if (a != 4){
                int t = min(s + 2, TARGET);
                MYADD(dp[i][t][0], dp[i - 1][s][0]);
                MYADD(dp[i][t][1], dp[i - 1][s][1]);
            }
        }
    }
    int res = 0;
    for (int s = 0; s <= BOUND; s++){
        MYADD(res, dp[n][s][1]);
        if (s >= TARGET)
            MYADD(res, dp[n][s][0]);
    }
    printf("%d\n", res);
    return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
const int N=2e3+10;
const int K=11;
typedef __int64 LL;
const int mod=1e9+7;
LL dp[N][1<<K];
LL biao[N];
int sum[N];

int aa[N];
void init(){
    biao[0]=1;
    for(int i=1;i<=2000;i++){
        biao[i]=biao[i-1]*2;biao[i]%=mod;
    }
}
int f(int sta,int a){
    if(a==2){
        return sta+1;
    }
    else {
        if(sta%2==1)return 2;
        else return sta+2;
    }
}
int main(){
    #ifdef DouBi
    freopen("in.cpp","r",stdin);
    #endif // DouBi
    init();
    int n,k;
    while(scanf("%d%d",&n,&k)!=EOF){
        sum[0]=0;
        for(int i=1;i<=n;i++){
            scanf("%d",&aa[i]);
            if(aa[i]==0){
                sum[i]=sum[i-1]+1;
            }
            else sum[i]=sum[i-1];
        }
        memset(dp,0,sizeof(dp));
        dp[0][0]=1;
        int ed=1<<(k-1);
        LL ans=0;
        for(int i=0;i<n;i++){
            for(int j=0;j<ed;j++)if(dp[i][j]){
                if(aa[i+1]!=0){
                    int x=f(j,aa[i+1]);
                    //printf("%d %d %d\n",i,j,x);
                    if(x>=ed){
                        ans+=dp[i][j]*biao[sum[n]-sum[i]];ans%=mod;
                    }
                    else {
                        dp[i+1][x]+=dp[i][j];dp[i+1][x]%=mod;
                    }
                }
                else {
                    int x=f(j,2);
                    if(x>=ed){
                        ans+=dp[i][j]*biao[sum[n]-sum[i]];ans%=mod;
                    }
                    else {
                        dp[i+1][x]+=dp[i][j];dp[i+1][x]%=mod;
                    }

                    x=f(j,4);
                    if(x>=ed){
                        ans+=dp[i][j]*biao[sum[n]-sum[i]];ans%=mod;
                    }
                    else {
                        dp[i+1][x]+=dp[i][j];dp[i+1][x]%=mod;
                    }
                }
            }
        }
        printf("%I64d\n",ans);
    }
    return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
const int N=2e3+10;
const int K=11;
typedef __int64 LL;
const int mod=1e9+7;
LL dp[N][1<<K];
LL biao[N];
int sum[N];

int aa[N];
void init(){
    biao[0]=1;
    for(int i=1;i<=2000;i++){
        biao[i]=biao[i-1]*2;biao[i]%=mod;
    }
}
int f(int sta,int a){
    if(a==2){
        return sta+1;
    }
    else {
        if(sta%2==1)return 2;
        else return sta+2;
    }
}
int main(){
    #ifdef DouBi
    freopen("in.cpp","r",stdin);
    #endif // DouBi
    init();
    int n,k;
    while(scanf("%d%d",&n,&k)!=EOF){
        sum[0]=0;
        for(int i=1;i<=n;i++){
            scanf("%d",&aa[i]);
            if(aa[i]==0){
                sum[i]=sum[i-1]+1;
            }
            else sum[i]=sum[i-1];
        }
        memset(dp,0,sizeof(dp));
        dp[0][0]=1;
        int ed=1<<(k-1);
        LL ans=0;
        for(int i=0;i<n;i++){
            for(int j=0;j<ed;j++)if(dp[i][j]){
                if(aa[i+1]!=0){
                    int x=f(j,aa[i+1]);
                    //printf("%d %d %d\n",i,j,x);
                    if(x>=ed){
                        ans+=dp[i][j]*biao[sum[n]-sum[i+1]];ans%=mod;
                    }
                    else {
                        dp[i+1][x]+=dp[i][j];dp[i+1][x]%=mod;
                    }
                }
                else {
                    int x=f(j,2);
                    //printf("%d %d %d\n",i,j,x);
                    if(x>=ed){
                        ans+=dp[i][j]*biao[sum[n]-sum[i+1]];ans%=mod;
                    }
                    else {
                        dp[i+1][x]+=dp[i][j];dp[i+1][x]%=mod;
                    }

                    x=f(j,4);
                    //printf("%d %d %d\n",i,j,x);
                    if(x>=ed){
                        ans+=dp[i][j]*biao[sum[n]-sum[i+1]];ans%=mod;
                    }
                    else {
                        dp[i+1][x]+=dp[i][j];dp[i+1][x]%=mod;
                    }
                }
            }
        }
        printf("%I64d\n",ans);
    }
    return 0;
}


#include <iostream>
#include <cstring>

using namespace std;

const int MAXN = 2010;
const int MAXK = 12;
const int MOD = 1000000007;

int N, K;
int A[MAXN];
int DP[MAXN][1 << MAXK][2];

int solve(int ind, int msk, int win) {
  if (ind == N) {
    return win;
  }

  int& ret = DP[ind][msk][win];
  if (ret == -1) {
    ret = 0;
    if (A[ind] == 0 || A[ind] == 2) {
      int nmsk = msk + 2;
      int nwin = win;
      if (nmsk >= 1 << K) nwin = 1;
      ret += solve(ind + 1, nmsk, nwin);
      ret %= MOD;
    }
    if (A[ind] == 0 || A[ind] == 4) {
      int nmsk = 4;
      if (msk % 4 == 0) nmsk += msk;
      int nwin = win;
      if (nmsk >= 1 << K) nwin = 1;
      ret += solve(ind + 1, nmsk, nwin);
      ret %= MOD;
    }
  }
  return ret;
}

int main() {
  cin >> N >> K;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }

  memset(DP, -1, sizeof(DP));
  int res = solve(0, 0, 0);
  cout << res << endl;
  return 0;
}


#include <iostream>
#include <cstring>

using namespace std;

const int MAXN = 2010;
const int MAXK = 12;
const int MOD = 1E9 + 7;

int N, K;
int A[MAXN];
int DP[MAXN][1 << MAXK][2];

int solve(int ind, int msk, int win) {
  if (ind == N) {
    return win;
  }

  int& ret = DP[ind][msk][win];
  if (ret < 0) {
    ret = 0;
    if (A[ind] == 0 || A[ind] == 2) {
      int nmsk = msk + 2;
      int nwin = win;
      if (nmsk >= (1 << K)) nwin = 1;
      ret += solve(ind + 1, nmsk, nwin);
      ret %= MOD;
    }
    if (A[ind] == 0 || A[ind] == 4) {
      int nmsk = 4;
      if (msk % 4 == 0) nmsk += msk;
      int nwin = win;
      if (nmsk >= (1 << K)) nwin = 1;
      ret += solve(ind + 1, nmsk, nwin);
      ret %= MOD;
    }
  }
  return ret;
}

int main() {
  cin >> N >> K;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }

  memset(DP, -1, sizeof(DP));
  int res = solve(0, 0, 0);
  cout << res << endl;
  return 0;
}


#include<stdio.h>

int main(){
	long long int n,k,x,set,total=0;
	scanf("%lld%lld", &n,&k);
	long long int drink[k+5];

	(n%2==0)? set=n/2 : set=n/2+1;

	for(int i=0; i<n; i++){
		drink[i]=0;
	}

	for(int i=0; i<n; i++){
		scanf("%lld", &x);
		drink[x]++;

		if(drink[x]==2){ total+=2; drink[x]-=2; set--; }

	}

	printf("%lld", total+set);
}


#include<stdio.h>

int main(){
	int n,k,x,set,total=0;
	scanf("%d%d", &n,&k);
	int drink[k+5];

	(n%2==0)? set=n/2 : set=n/2+1;

	for(int i=0; i<n; i++){
		drink[i]=0;
	}

	for(int i=0; i<n; i++){
		scanf("%d", &x);
		drink[x]++;

		if(drink[x]==2){ total+=2; drink[x]-=2; set--; }

	}

	printf("%d", total+set);
}


#include<stdio.h>

int main(){
	int m,n;
	scanf("%d%d", &m,&n);
	int ans=0;
	for(int i=0; i<n; i++){
		int arr;
		scanf("%d", &arr);
		if(arr==m){
			ans++;
		}
	}
	printf("%d\n", ans);
}


#include<stdio.h>

int main(){
	int n,k,x,set,total=0;
	scanf("%d%d", &n,&k);
	int drink[k+50];

	(n%2==0)? set=n/2 : set=n/2+1;

	for(int i=0; i<k; i++){
		drink[i]=0;
	}

	for(int i=0; i<n; i++){
		scanf("%d", &x);
		drink[x]++;

		if(drink[x]==2){ total+=2; drink[x]-=2; set--; }

	}

	printf("%d", total+set);
}


#include<bits/stdc++.h>
using namespace std;
const long long llINF = 9223372036854775807;
const int INF = 2147483647;
const int maxn = 1e5 + 7;
const int mod = 1e9 + 7;
int n, k, ans;
int cnt[1007];

int main(int argc, char const *argv[])
{
	scanf("%d%d", &n, &k);
	int num = (n + 1) / 2;

	for (int i = 1; i <= n; i++)
	{
		int x;
		scanf("%d", &x);
		cnt[x]++;
	}

	for (int i = 1; i <= n; i++)
	{
		int tmp = cnt[i] / 2;
		ans += min(tmp, num) * 2;
		num -= min(tmp, num);
	}

	for (int i = 1; i <= n; i++)
	{
		if (num)
		{
			ans++;
			num--;
		}
	}

	printf("%d\n", ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long long llINF = 9223372036854775807;
const int INF = 2147483647;
const int maxn = 1e5 + 7;
const int mod = 1e9 + 7;

int n, k, ans;

int cnt[1007];
bool vis[1007];

int main(int argc, char const *argv[])
{
	scanf("%d%d", &n, &k);
	int num = (n + 1) / 2;
	for (int i = 1; i <= n; i++)
	{
		int x;
		scanf("%d", &x);
		cnt[x]++;
	}

	for (int i = 1000; i >= 1; i--)
	{
		if (cnt[i] % 2 == 0)
		{
			num -= cnt[i] / 2;
			ans += cnt[i];
		}
		else
		{
			num -= cnt[i] / 2;
			ans += cnt[i] - 1;
			vis[i] = 1;
		}
	}

	for (int i = 1; i <= 1000; i++)
		if (vis[i] && num > 0)
		{
			vis[i] = 0;
			num -= 1;
			ans += 1;
		}

	printf("%d\n", ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long long llINF = 9223372036854775807;
const int INF = 2147483647;
const int maxn = 1e5 + 7;
const int mod = 1e9 + 7;

int n, k, ans;

int cnt[1007];

int main(int argc, char const *argv[])
{
	scanf("%d%d", &n, &k);
	int num = (n + 1) / 2;

	for (int i = 1; i <= n; i++)
	{
		int x;
		scanf("%d", &x);
		cnt[x]++;
	}

	for (int i = 1; i <= n; i++)
	{
		while (cnt[i] >= 2 && num)
		{
			num--;
			ans += 2;
			cnt[i] -= 2;
		}
	}

	ans += num;

	printf("%d\n", ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long long llINF = 9223372036854775807;
const int INF = 2147483647;
const int maxn = 1e5 + 7;
const int mod = 1e9 + 7;

int n, k, ans;

int cnt[1007];

int main(int argc, char const *argv[])
{
	scanf("%d%d", &n, &k);
	int num = (n + 1) / 2;

	for (int i = 1; i <= n; i++)
	{
		int x;
		scanf("%d", &x);
		cnt[x]++;
	}

	for (int i = 1; i <= n; i++)
	{
		while (cnt[i] >= 2 && num)
		{
			num--;
			ans += 2;
			cnt[i] -= 2;
		}
	}

    for (int i = 1; i <= n; i++)
	{
		while (cnt[i] >= 1 && num)
		{
			num--;
			ans += 1;
			cnt[i] -= 1;
		}
	}

	printf("%d\n", ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long long llINF = 9223372036854775807;
const int INF = 2147483647;
const int maxn = 1e5 + 7;
const int mod = 1e9 + 7;
int n, k, ans;

int cnt[1007];

int main(int argc, char const *argv[])
{
	scanf("%d%d", &n, &k);
	int num = (n + 1) / 2;

	for (int i = 1; i <= n; i++)
	{
		int x;
		scanf("%d", &x);
		cnt[x]++;
	}

	for (int i = 1; i <= n; i++)
	{
		int tmp = cnt[i] / 2;
		ans += min(tmp, num) * 2;
		num -= min(tmp, num);
		cnt[i] -= tmp * 2;
	}

	for (int i = 1; i <= n; i++)
	{
		if (num)
		{
			ans++;
			num--;
		}
	}

	printf("%d\n", ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long long llINF = 9223372036854775807;
const int INF = 2147483647;
const int maxn = 1e5 + 7;
const int mod = 1e9 + 7;
int n, k, ans;

int cnt[1007];

int main(int argc, char const *argv[])
{
	scanf("%d%d", &n, &k);
	int num = (n + 1) / 2;

	for (int i = 1; i <= n; i++)
	{
		int x;
		scanf("%d", &x);
		cnt[x]++;
	}

	for (int i = 1; i <= n; i++)
	{
		int tmp = cnt[i] / 2;
		ans += min(tmp, num) * 2;
		num -= min(tmp, num);
		cnt[i] -= tmp * 2;
	}

	for (int i = 1; i <= n; i++)
	{
		if (num)
		{
			if (cnt[i])
			{
				ans++;
				num--;
			}
		}
	}

	printf("%d\n", ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define m_p make_pair
#define pb push_back
#define ppb pop_back
#define f first
#define s second
#define pii pair<int,int>
#define ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define double long double
const double pi=3.14159265358979;
const   int  mod=1e9+7;
int takemod(int a,int mod){return ((a%mod)+mod)%mod;}
int  bs(int  a[], int  l, int  r, int  x){if(r>=l){ int  mid=(l+r)/2;if(a[mid]==x)return mid;else if(a[mid]>x)return bs(a,l,mid-1,x); else return bs(a,mid+1,r,x);}return -1;}
int  s_t_i(string s){stringstream geek(s); int  m;geek>>m;return m;}
int  power(int  b, int  p){if(p==0)return 1;else if(p%2==0)return (power(b,p/2)*(power(b,p/2)));else return ((b)*(power(b,p-1)));}
bool isprime( int  n){if(n==1)return false;if(n==2 or n==3)return true; int  lim=sqrt(n); int  i=2;while(i<=lim){if(n%i==0)return false; i++;}return true;}
vector< int > factors( int  n){vector< int > a;a.pb(1); int  lim=sqrt(n),i=2;while(i<=lim){if(n%i==0){a.pb(i);if(i!=n/i)a.pb(n/i);}i++;}if(n!=1)a.pb(n);sort(a.begin(),a.end());return a;}
vector<pii> pf_with_count(int  b){ pii p;vector<pii>pf;int  count=0;while(b%2==0){b/=2;count++;}if(count>0){p.f=2;p.s=count;pf.pb(p);}int i=3;while(i<=sqrt(b)){count=0;while(b%i==0){b/=i;count++;}if(count>0){p.f=i;p.s=count;pf.pb(p);}i+=2;}if(b>2) {p.f=b;p.s=1;pf.pb(p);}return pf;}
int  bs_t_i(string s){int  l=strtoull(s.c_str(),NULL,2);return l;}
string  i_to_bs(int  n){string s = bitset< 5 >( n ).to_string();return s;}
signed main()
{
 ios;
 int n,k;
 int arr[1001];
 fill(arr,arr+1001,0);
 cin>>n>>k;
 int a[n];
 int i=0;
 while(i<n)
 {
 	cin>>a[i];
 	arr[a[i]]++;
 	i++;
 }
 int count=n/2;
 if(n%2!=0)count++;
 i=0;
 sort(arr,arr+k+1,greater<int>());
 while(i<=k)
 {
 	while(count>0 and arr[i]>0)
 	{
 		count--;
 		arr[i]-=2;
 	}
 	//cout<<arr[i]<<" "<<count<<endl;
 	i++;
 }

 i=0;
 count=0;
 while(i<=k)
 {
 	if(arr[i]>0)count+=arr[i];
 	i++;
 }
 cout<<n-count;

}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define m_p make_pair
#define pb push_back
#define ppb pop_back
#define f first
#define s second
#define pii pair<int,int>
#define ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define double long double
const double pi=3.14159265358979;
const   int  mod=1e9+7;
int takemod(int a,int mod){return ((a%mod)+mod)%mod;}
int  bs(int  a[], int  l, int  r, int  x){if(r>=l){ int  mid=(l+r)/2;if(a[mid]==x)return mid;else if(a[mid]>x)return bs(a,l,mid-1,x); else return bs(a,mid+1,r,x);}return -1;}
int  s_t_i(string s){stringstream geek(s); int  m;geek>>m;return m;}
int  power(int  b, int  p){if(p==0)return 1;else if(p%2==0)return (power(b,p/2)*(power(b,p/2)));else return ((b)*(power(b,p-1)));}
bool isprime( int  n){if(n==1)return false;if(n==2 or n==3)return true; int  lim=sqrt(n); int  i=2;while(i<=lim){if(n%i==0)return false; i++;}return true;}
vector< int > factors( int  n){vector< int > a;a.pb(1); int  lim=sqrt(n),i=2;while(i<=lim){if(n%i==0){a.pb(i);if(i!=n/i)a.pb(n/i);}i++;}if(n!=1)a.pb(n);sort(a.begin(),a.end());return a;}
vector<pii> pf_with_count(int  b){ pii p;vector<pii>pf;int  count=0;while(b%2==0){b/=2;count++;}if(count>0){p.f=2;p.s=count;pf.pb(p);}int i=3;while(i<=sqrt(b)){count=0;while(b%i==0){b/=i;count++;}if(count>0){p.f=i;p.s=count;pf.pb(p);}i+=2;}if(b>2) {p.f=b;p.s=1;pf.pb(p);}return pf;}
int  bs_t_i(string s){int  l=strtoull(s.c_str(),NULL,2);return l;}
string  i_to_bs(int  n){string s = bitset< 5 >( n ).to_string();return s;}

signed main()
{
 ios;
 int arr[1001];
 fill(arr,arr+1001,0);
 int n,k;
 cin>>n>>k;
 int a[n];
 int i=0;
 while(i<n)
 {
 	cin>>a[i];
 	arr[a[i]]++;
 	i++;
 }
 int count=n/2;
 if(n%2!=0)count++;
 i=1;
 while(i<=k)
 {
 	while(arr[i]%2==0 and count>0 and arr[i]>0)
 	{
 		count--;
 		arr[i]-=2;
 	}
 	i++;
 }
 i=1;
 while(i<=k)
 {
    while(arr[i]>0 and count>0)
    {
    	arr[i]-=2;
    	count--;
    }
    i++;
 }
 i=1;
 count=0;
 while(i<=k)
 {
 	if(arr[i]>0)count+=arr[i];
 	i++;
 }
 cout<<n-count;

}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define m_p make_pair
#define pb push_back
#define ppb pop_back
#define f first
#define s second
#define pii pair<int,int>
#define ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define double long double
const double pi=3.14159265358979;
const   int  mod=1e9+7;
int takemod(int a,int mod){return ((a%mod)+mod)%mod;}
int  bs(int  a[], int  l, int  r, int  x){if(r>=l){ int  mid=(l+r)/2;if(a[mid]==x)return mid;else if(a[mid]>x)return bs(a,l,mid-1,x); else return bs(a,mid+1,r,x);}return -1;}
int  s_t_i(string s){stringstream geek(s); int  m;geek>>m;return m;}
int  power(int  b, int  p){if(p==0)return 1;else if(p%2==0)return (power(b,p/2)*(power(b,p/2)));else return ((b)*(power(b,p-1)));}
bool isprime( int  n){if(n==1)return false;if(n==2 or n==3)return true; int  lim=sqrt(n); int  i=2;while(i<=lim){if(n%i==0)return false; i++;}return true;}
vector< int > factors( int  n){vector< int > a;a.pb(1); int  lim=sqrt(n),i=2;while(i<=lim){if(n%i==0){a.pb(i);if(i!=n/i)a.pb(n/i);}i++;}if(n!=1)a.pb(n);sort(a.begin(),a.end());return a;}
vector<pii> pf_with_count(int  b){ pii p;vector<pii>pf;int  count=0;while(b%2==0){b/=2;count++;}if(count>0){p.f=2;p.s=count;pf.pb(p);}int i=3;while(i<=sqrt(b)){count=0;while(b%i==0){b/=i;count++;}if(count>0){p.f=i;p.s=count;pf.pb(p);}i+=2;}if(b>2) {p.f=b;p.s=1;pf.pb(p);}return pf;}
int  bs_t_i(string s){int  l=strtoull(s.c_str(),NULL,2);return l;}
string  i_to_bs(int  n){string s = bitset< 5 >( n ).to_string();return s;}

signed main()
{
 ios;
 int n,k;
 cin>>n>>k;
 int a[n];
 int arr[k+1];
 fill(arr,arr+k+1,0);
 int i=0;
 while(i<n)
 {
 	cin>>a[i];
 	arr[a[i]]++;
 	i++;
 }
 int count=n/2;
 if(n%2!=0)count++;
 i=1;
 sort(arr+1,arr+k+1,greater<int>());
 while(i<=k)
 {
    while(arr[i]>1 and count>0)
    {
    	arr[i]-=2;
    	count--;
    }
    i++;
 }
 i=1;
 while(i<=k)
 {
 	while(count>0 and arr[i]>0)
 	{
 		count--;
 		arr[i]-=2;
 	}
 	i++;
 }
 i=1;
 count=0;
 while(i<=k)
 {
 	if(arr[i]>0)count+=arr[i];
 	i++;
 }
 cout<<n-count;

}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define m_p make_pair
#define pb push_back
#define ppb pop_back
#define f first
#define s second
#define pii pair<int,int>
#define ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define double long double
const double pi=3.14159265358979;
const   int  mod=1e9+7;
int takemod(int a,int mod){return ((a%mod)+mod)%mod;}
int  bs(int  a[], int  l, int  r, int  x){if(r>=l){ int  mid=(l+r)/2;if(a[mid]==x)return mid;else if(a[mid]>x)return bs(a,l,mid-1,x); else return bs(a,mid+1,r,x);}return -1;}
int  s_t_i(string s){stringstream geek(s); int  m;geek>>m;return m;}
int  power(int  b, int  p){if(p==0)return 1;else if(p%2==0)return (power(b,p/2)*(power(b,p/2)));else return ((b)*(power(b,p-1)));}
bool isprime( int  n){if(n==1)return false;if(n==2 or n==3)return true; int  lim=sqrt(n); int  i=2;while(i<=lim){if(n%i==0)return false; i++;}return true;}
vector< int > factors( int  n){vector< int > a;a.pb(1); int  lim=sqrt(n),i=2;while(i<=lim){if(n%i==0){a.pb(i);if(i!=n/i)a.pb(n/i);}i++;}if(n!=1)a.pb(n);sort(a.begin(),a.end());return a;}
vector<pii> pf_with_count(int  b){ pii p;vector<pii>pf;int  count=0;while(b%2==0){b/=2;count++;}if(count>0){p.f=2;p.s=count;pf.pb(p);}int i=3;while(i<=sqrt(b)){count=0;while(b%i==0){b/=i;count++;}if(count>0){p.f=i;p.s=count;pf.pb(p);}i+=2;}if(b>2) {p.f=b;p.s=1;pf.pb(p);}return pf;}
int  bs_t_i(string s){int  l=strtoull(s.c_str(),NULL,2);return l;}
string  i_to_bs(int  n){string s = bitset< 5 >( n ).to_string();return s;}

signed main()
{
 ios;
 int arr[1001];
 fill(arr,arr+1001,0);
 int n,k;
 cin>>n>>k;
 int a[n];
 int i=0;
 while(i<n)
 {
 	cin>>a[i];
 	arr[a[i]]++;
 	i++;
 }
 int count=n/2;
 if(n%2!=0)count++;
 i=1;
 while(i<=k)
 {
 	while(arr[i]%2==0 and count>0 and arr[i]>0)
 	{
 		count--;
 		arr[i]-=2;
 	}
 	i++;
 }
 sort(arr+1,arr+k+1,greater<int>());
 i=1;
 while(i<=k)
 {
    while(arr[i]>0 and count>0)
    {
    	arr[i]-=2;
    	count--;
    }
    i++;
 }
 i=1;
 count=0;
 while(i<=k)
 {
 	if(arr[i]>0)count++;
 	i++;
 }
 cout<<n-count;

}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define m_p make_pair
#define pb push_back
#define ppb pop_back
#define f first
#define s second
#define pii pair<int,int>
#define ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define double long double
const double pi=3.14159265358979;
const   int  mod=1e9+7;
int takemod(int a,int mod){return ((a%mod)+mod)%mod;}
int  bs(int  a[], int  l, int  r, int  x){if(r>=l){ int  mid=(l+r)/2;if(a[mid]==x)return mid;else if(a[mid]>x)return bs(a,l,mid-1,x); else return bs(a,mid+1,r,x);}return -1;}
int  s_t_i(string s){stringstream geek(s); int  m;geek>>m;return m;}
int  power(int  b, int  p){if(p==0)return 1;else if(p%2==0)return (power(b,p/2)*(power(b,p/2)));else return ((b)*(power(b,p-1)));}
bool isprime( int  n){if(n==1)return false;if(n==2 or n==3)return true; int  lim=sqrt(n); int  i=2;while(i<=lim){if(n%i==0)return false; i++;}return true;}
vector< int > factors( int  n){vector< int > a;a.pb(1); int  lim=sqrt(n),i=2;while(i<=lim){if(n%i==0){a.pb(i);if(i!=n/i)a.pb(n/i);}i++;}if(n!=1)a.pb(n);sort(a.begin(),a.end());return a;}
vector<pii> pf_with_count(int  b){ pii p;vector<pii>pf;int  count=0;while(b%2==0){b/=2;count++;}if(count>0){p.f=2;p.s=count;pf.pb(p);}int i=3;while(i<=sqrt(b)){count=0;while(b%i==0){b/=i;count++;}if(count>0){p.f=i;p.s=count;pf.pb(p);}i+=2;}if(b>2) {p.f=b;p.s=1;pf.pb(p);}return pf;}
int  bs_t_i(string s){int  l=strtoull(s.c_str(),NULL,2);return l;}
string  i_to_bs(int  n){string s = bitset< 5 >( n ).to_string();return s;}

signed main()
{
 ios;
 int n,k;
 cin>>n>>k;
 int a[n];
 int arr[k+1];
 fill(arr,arr+k+1,0);
 int i=0;
 while(i<n)
 {
 	cin>>a[i];
 	arr[a[i]]++;
 	i++;
 }
 int count=n/2;
 if(n%2!=0)count++;
 i=1;
 while(i<=k)
 {
    while(arr[i]>1 and count>0)
    {
    	arr[i]-=2;
    	count--;
    }
    i++;
 }
 i=1;
 while(i<=k)
 {
 	while(count>0 and arr[i]>0)
 	{
 		count--;
 		arr[i]-=2;
 	}
 	i++;
 }
 i=1;
 count=0;
 while(i<=k)
 {
 	if(arr[i]>0)count+=arr[i];
 	i++;
 }
 cout<<n-count;

}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define m_p make_pair
#define pb push_back
#define ppb pop_back
#define f first
#define s second
#define pii pair<int,int>
#define ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define double long double
const double pi=3.14159265358979;
const   int  mod=1e9+7;
int takemod(int a,int mod){return ((a%mod)+mod)%mod;}
int  bs(int  a[], int  l, int  r, int  x){if(r>=l){ int  mid=(l+r)/2;if(a[mid]==x)return mid;else if(a[mid]>x)return bs(a,l,mid-1,x); else return bs(a,mid+1,r,x);}return -1;}
int  s_t_i(string s){stringstream geek(s); int  m;geek>>m;return m;}
int  power(int  b, int  p){if(p==0)return 1;else if(p%2==0)return (power(b,p/2)*(power(b,p/2)));else return ((b)*(power(b,p-1)));}
bool isprime( int  n){if(n==1)return false;if(n==2 or n==3)return true; int  lim=sqrt(n); int  i=2;while(i<=lim){if(n%i==0)return false; i++;}return true;}
vector< int > factors( int  n){vector< int > a;a.pb(1); int  lim=sqrt(n),i=2;while(i<=lim){if(n%i==0){a.pb(i);if(i!=n/i)a.pb(n/i);}i++;}if(n!=1)a.pb(n);sort(a.begin(),a.end());return a;}
vector<pii> pf_with_count(int  b){ pii p;vector<pii>pf;int  count=0;while(b%2==0){b/=2;count++;}if(count>0){p.f=2;p.s=count;pf.pb(p);}int i=3;while(i<=sqrt(b)){count=0;while(b%i==0){b/=i;count++;}if(count>0){p.f=i;p.s=count;pf.pb(p);}i+=2;}if(b>2) {p.f=b;p.s=1;pf.pb(p);}return pf;}
int  bs_t_i(string s){int  l=strtoull(s.c_str(),NULL,2);return l;}
string  i_to_bs(int  n){string s = bitset< 5 >( n ).to_string();return s;}

signed main()
{
 ios;
 int n,k;
 cin>>n>>k;
 int a[n];
 int arr[k+1];
 fill(arr,arr+k+1,0);
 int i=0;
 while(i<n)
 {
 	cin>>a[i];
 	arr[a[i]]++;
 	i++;
 }
 int count=n/2;
 if(n%2!=0)count++;
 i=1;
 sort(arr+1,arr+k+1,greater<int>());
 while(i<=k)
 {
 	while(arr[i]%2==0 and count>0 and arr[i]>0)
 	{
 		count--;
 		arr[i]-=2;
 	}
 	i++;
 }
 sort(arr+1,arr+k+1,greater<int>());
 i=1;
 while(i<=k)
 {
    while(arr[i]>0 and count>0)
    {
    	arr[i]-=2;
    	count--;
    }
    i++;
 }
 i=1;
 count=0;
 while(i<=k)
 {
 	if(arr[i]>0)count+=arr[i];
 	i++;
 }
 cout<<n-count;

}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define m_p make_pair
#define pb push_back
#define ppb pop_back
#define f first
#define s second
#define pii pair<int,int>
#define ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define double long double
const double pi=3.14159265358979;
const   int  mod=1e9+7;
int takemod(int a,int mod){return ((a%mod)+mod)%mod;}
int  bs(int  a[], int  l, int  r, int  x){if(r>=l){ int  mid=(l+r)/2;if(a[mid]==x)return mid;else if(a[mid]>x)return bs(a,l,mid-1,x); else return bs(a,mid+1,r,x);}return -1;}
int  s_t_i(string s){stringstream geek(s); int  m;geek>>m;return m;}
int  power(int  b, int  p){if(p==0)return 1;else if(p%2==0)return (power(b,p/2)*(power(b,p/2)));else return ((b)*(power(b,p-1)));}
bool isprime( int  n){if(n==1)return false;if(n==2 or n==3)return true; int  lim=sqrt(n); int  i=2;while(i<=lim){if(n%i==0)return false; i++;}return true;}
vector< int > factors( int  n){vector< int > a;a.pb(1); int  lim=sqrt(n),i=2;while(i<=lim){if(n%i==0){a.pb(i);if(i!=n/i)a.pb(n/i);}i++;}if(n!=1)a.pb(n);sort(a.begin(),a.end());return a;}
vector<pii> pf_with_count(int  b){ pii p;vector<pii>pf;int  count=0;while(b%2==0){b/=2;count++;}if(count>0){p.f=2;p.s=count;pf.pb(p);}int i=3;while(i<=sqrt(b)){count=0;while(b%i==0){b/=i;count++;}if(count>0){p.f=i;p.s=count;pf.pb(p);}i+=2;}if(b>2) {p.f=b;p.s=1;pf.pb(p);}return pf;}
int  bs_t_i(string s){int  l=strtoull(s.c_str(),NULL,2);return l;}
string  i_to_bs(int  n){string s = bitset< 5 >( n ).to_string();return s;}

signed main()
{
 ios;
 int arr[1001];
 fill(arr,arr+1001,0);
 int n,k;
 cin>>n>>k;
 int a[n];
 int i=0;
 while(i<n)
 {
 	cin>>a[i];
 	arr[a[i]]++;
 	i++;
 }
 int count=n/2;
 if(n%2!=0)count++;
 i=1;
 while(i<=k)
 {
 	while(arr[i]%2==0 and count>0 and arr[i]>0)
 	{
 		count--;
 		arr[i]-=2;
 	}
 	i++;
 }
 sort(arr+1,arr+k+1,greater<int>());
 i=1;
 while(i<=k)
 {
    while(arr[i]>0 and count>0)
    {
    	arr[i]-=2;
    	count--;
    }
    i++;
 }
 i=1;
 count=0;
 while(i<=k)
 {
 	if(arr[i]>0)count+=arr[i];
 	i++;
 }
 cout<<n-count;

}


#include<bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long n,k;
    cin>>n>>k;
    long long p=n;
    long long m = ceil((double)n/2);
    vector<long long> v(k+1,0);
    while(n--){
        long long a;
        cin>>a;
        v[a]++;
    }
    sort(v.begin(),v.end(),greater<long long> ());
    long long res=0;
    long long i=0;
    while(m>0 && i<=k){
        if(2*m>=v[i]){
            res+=v[i];
        }
        else{
            res+=2*m;
        }
        m-=ceil((double)v[i]/2);
        i++;
    }
    cout<<p-res<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long n,k;
    cin>>n>>k;
    long long p=n;
    long long m = ceil((double)n/2);
    vector<long long> v(k+1,0);
    while(n--){
        long long a;
        cin>>a;
        v[a]++;
    }
    sort(v.begin(),v.end(),greater<long long> ());
    long long res=0;
    long long i=0;
    while(m!=0){
        m-=ceil((double)v[i]/2);
        res+=v[i];
        i++;
    }
    cout<<p-res<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long n,k;
    cin>>n>>k;
    long long p=n;
    long long m = ceil((double)n/2);
    vector<long long> v(k+1,0);
    while(n--){
        long long a;
        cin>>a;
        v[a]++;
    }
    sort(v.begin(),v.end(),greater<long long> ());
    long long res=0;
    long long i=0;
    while(m>0 && i<k){
        if(2*m>=v[i]){
            res+=v[i];
            m-=(v[i]+1)/2;
        }
        else{
            res+=2*m;
            m=0;
        }
        i++;
    }
    cout<<res<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long n,k;
    cin>>n>>k;
    long long p=n;
    vector<long long> v(k+1,0);
    while(n--){
        long long a;
        cin>>a;
        v[a]++;
    }
    long long odd = 0;
    for(auto a:v){
    	if(a&1) odd++;
    }
    odd>>=1;
    cout<<p-odd<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long n,k;
    cin>>n>>k;
    long long p=n;
    long long m = ceil((double)n/2);
    vector<long long> v(k+1,0);
    while(n--){
        long long a;
        cin>>a;
        v[a]++;
    }
    sort(v.begin(),v.end(),greater<long long> ());
    long long res=0;
    long long i=0;
    while(m>0 && i<k){
        if(2*m>=v[i]){
            res+=v[i];
            m-=(v[i]+1)/2;
        }
        else{
            if(v[i]>0)
            {
                res+=2*m;
                m=0;
            }
        }
        i++;
    }
    cout<<res<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long n,k;
    cin>>n>>k;
    long long p=n;
    long long m = ceil((double)n/2);
    vector<long long> v(k+1,0);
    while(n--){
        long long a;
        cin>>a;
        v[a]++;
    }
    sort(v.begin(),v.end(),greater<long long> ());
    long long res=0;
    long long i=0;
    while(m>0 && i<=k){
        if(2*m>=v[i]){
            res+=v[i];
        }
        else{
            res+=2*m;
        }
        m-=ceil((double)v[i]/2);
        i++;
    }
    cout<<res<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define min(x,y) (x < y? x:y)
#define max(x,y) (x>y?x:y)
#define vi vector <int>
#define pb push_back
#define pob pop_back
#define pi pair <int,int>
#define F first
#define S second
#define MP make_pair
#define FOR(a,b) for(int a=0;a<b;a++)
#define FORL(a,b,c) for(int a=b;a<=b;a++)
#define FORR(a,b,c) for(int a=b;a>=b;a--)
int main()
{
    ll n,k;
    cin>>n>>k;
    vi v;
    FOR(i,n)
    {
        ll a;
        v.pb(a);
    }

    ll sum=0;

    if((n%2)==0)
    {
        for(ll i=1;i<=k;i++)
        {
            ll x=count(v.begin(),v.end(),k);
            if((x%2)!=0)
            sum=sum+1;
        }
        cout<<n-(sum)/2<<endl;
    }
    if((n%2)!=0)
    {
        for(ll i=1;i<=k;i++)
        {
            ll x=count(v.begin(),v.end(),k);
            if((x%2)!=0)
            sum=sum+1;
            cout<<x<<" ";
        }
        cout<<n-(sum-1)/2<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define min(x,y) (x < y? x:y)
#define max(x,y) (x>y?x:y)
#define vi vector <int>
#define pb push_back
#define pob pop_back
#define pi pair <int,int>
#define F first
#define S second
#define MP make_pair
#define FOR(a,b) for(int a=0;a<b;a++)
#define FORL(a,b,c) for(int a=b;a<=b;a++)
#define FORR(a,b,c) for(int a=b;a>=b;a--)
int main()
{
    ll n,k;
    cin>>n>>k;
    vi v;
    FOR(i,n)
    {
        ll a;
        v.pb(a);
    }

    ll sum=0;

    if((n%2)==0)
    {
        for(ll i=1;i<=k;i++)
        {
            ll x=count(v.begin(),v.end(),i);
            if((x%2)!=0)
            sum=sum+1;
        }
        cout<<n-(sum)/2<<endl;
    }
    if((n%2)!=0)
    {
        for(ll i=1;i<=k;i++)
        {
            ll x=count(v.begin(),v.end(),i);
            if((x%2)!=0)
            sum=sum+1;
            cout<<x<<" ";
        }
        cout<<n-(sum-1)/2<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define min(x,y) (x < y? x:y)
#define max(x,y) (x>y?x:y)
#define vi vector <int>
#define pb push_back
#define pob pop_back
#define pi pair <int,int>
#define F first
#define S second
#define MP make_pair
#define FOR(a,b) for(int a=0;a<b;a++)
#define FORL(a,b,c) for(int a=b;a<=b;a++)
#define FORR(a,b,c) for(int a=b;a>=b;a--)
int main()
{
    ll n,k;
    cin>>n>>k;
    vi v;
    FOR(i,n)
    {
        ll a;
        v.pb(a);
    }

    ll sum=0;

    if(n%2==0)
    {
        for(ll i=1;i<=k;i++)
        {
            ll x=count(v.begin(),v.end(),k);
            if(x%2!=0)
            sum=sum+1;
        }
        cout<<n-(sum)/2<<endl;
    }
    if(n%2!=0)
    {
        for(ll i=1;i<=k;i++)
        {
            ll x=count(v.begin(),v.end(),k);
            if(x%2!=0)
            sum=sum+1;
            cout<<sum<<" ";
        }
        cout<<n-(sum-1)/2<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define min(x,y) (x < y? x:y)
#define max(x,y) (x>y?x:y)
#define vi vector <int>
#define pb push_back
#define pob pop_back
#define pi pair <int,int>
#define F first
#define S second
#define MP make_pair
#define FOR(a,b) for(int a=0;a<b;a++)
#define FORL(a,b,c) for(int a=b;a<=b;a++)
#define FORR(a,b,c) for(int a=b;a>=b;a--)
int main()
{
    ll n,k;
    cin>>n>>k;
    vi v;
    FOR(i,n)
    {
        ll a;
        v.pb(a);
    }

    ll sum=0;

    if(n%2==0)
    {
        for(i=1;i<=k;i++)
        {
            ll x=count(v.begin(),v.end(),k);
            if(x%2!=0)
            sum=sum+1;
        }
        cout<<n-(sum)/2<<endl;
    }
    if(n%2!=0)
    {
        for(i=1;i<=k;i++)
        {
            ll x=count(v.begin(),v.end(),k);
            if(x%2!=0)
            sum=sum+1;
        }
        cout<<n-(sum-1)/2<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define min(x,y) (x < y? x:y)
#define max(x,y) (x>y?x:y)
#define vi vector <int>
#define pb push_back
#define pob pop_back
#define pi pair <int,int>
#define F first
#define S second
#define MP make_pair
#define FOR(a,b) for(int a=0;a<b;a++)
#define FORL(a,b,c) for(int a=b;a<=b;a++)
#define FORR(a,b,c) for(int a=b;a>=b;a--)
int main()
{
    ll n,k;
    cin>>n>>k;
    vi v;
    FOR(i,n)
    {
        ll a;
        v.pb(a);
    }

    ll sum=0;

    if(n%2==0)
    {
        for(ll i=1;i<=k;i++)
        {
            ll x=count(v.begin(),v.end(),k);
            if(x%2!=0)
            sum=sum+1;
        }
        cout<<n-(sum)/2<<endl;
    }
    if(n%2!=0)
    {
        for(ll i=1;i<=k;i++)
        {
            ll x=count(v.begin(),v.end(),k);
            if(x%2!=0)
            sum=sum+1;
        }
        cout<<n-(sum-1)/2<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define min(x,y) (x < y? x:y)
#define max(x,y) (x>y?x:y)
#define vi vector <int>
#define pb push_back
#define pob pop_back
#define pi pair <int,int>
#define F first
#define S second
#define MP make_pair
#define FOR(a,b) for(int a=0;a<b;a++)
#define FORL(a,b,c) for(int a=b;a<=b;a++)
#define FORR(a,b,c) for(int a=b;a>=b;a--)
int main()
{
    ll n,k;
    cin>>n>>k;
    vi v;
    FOR(i,n)
    {
        ll a;
        cin>>a;
        v.pb(a);
    }

    ll sum=0;

    if((n%2)==0)
    {
        for(ll i=1;i<=k;i++)
        {
            ll x=count(v.begin(),v.end(),i);
            if((x%2)!=0)
            sum=sum+1;
        }
        cout<<n-(sum)/2<<endl;
    }
    if((n%2)!=0)
    {
        for(ll i=1;i<=k;i++)
        {
            ll x=count(v.begin(),v.end(),i);
            if((x%2)!=0)
            sum=sum+1;

        }
        cout<<n-(sum-1)/2<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define min(x,y) (x < y? x:y)
#define max(x,y) (x>y?x:y)
#define vi vector <int>
#define pb push_back
#define pob pop_back
#define pi pair <int,int>
#define F first
#define S second
#define MP make_pair
#define FOR(a,b) for(int a=0;a<b;a++)
#define FORL(a,b,c) for(int a=b;a<=b;a++)
#define FORR(a,b,c) for(int a=b;a>=b;a--)
int main()
{
    ll n,k;
    cin>>n>>k;
    vi v;
    FOR(i,n)
    {
        ll a;
        v.pb(a);
    }

    ll sum=0;

    if(n%2==0)
    {
        FOR(i,k)
        {
            ll x=count(v.begin(),v.end(),k);
            if(x%2!=0)
            sum=sum+1;
        }
        cout<<n-(sum)/2<<endl;
    }
    if(n%2!=0)
    {
        FOR(i,k)
        {
            ll x=count(v.begin(),v.end(),k);
            if(x%2!=0)
            sum=sum+1;
        }
        cout<<n-(sum+1)/2<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define min(x,y) (x < y? x:y)
#define max(x,y) (x>y?x:y)
#define vi vector <int>
#define pb push_back
#define pob pop_back
#define pi pair <int,int>
#define F first
#define S second
#define MP make_pair
#define FOR(a,b) for(int a=0;a<b;a++)
#define FORL(a,b,c) for(int a=b;a<=b;a++)
#define FORR(a,b,c) for(int a=b;a>=b;a--)
int main()
{
    ll n,k;
    cin>>n>>k;
    vi v;
    FOR(i,n)
    {
        ll a;
        v.pb(a);
    }

    ll sum=0;

    if((n%2)==0)
    {
        for(ll i=1;i<=k;i++)
        {
            ll x=count(v.begin(),v.end(),k);
            if((x%2)!=0)
            sum=sum+1;
        }
        cout<<n-(sum)/2<<endl;
    }
    if((n%2)!=0)
    {
        for(ll i=1;i<=k;i++)
        {
            ll x=count(v.begin(),v.end(),k);
            if((x%2)!=0)
            sum=sum+1;
            cout<<sum<<" ";
        }
        cout<<n-(sum-1)/2<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define min(x,y) (x < y? x:y)
#define max(x,y) (x>y?x:y)
#define vi vector <int>
#define pb push_back
#define pob pop_back
#define pi pair <int,int>
#define F first
#define S second
#define MP make_pair
#define FOR(a,b) for(int a=0;a<b;a++)
#define FORL(a,b,c) for(int a=b;a<=b;a++)
#define FORR(a,b,c) for(int a=b;a>=b;a--)
int main()
{
    ll n,k;
    cin>>n>>k;
    vi v;
    FOR(i,n)
    {
        ll a;
        v.pb(a);
    }

    ll sum=0;

    if((n%2)==0)
    {
        for(ll i=1;i<=k;i++)
        {
            ll x=count(v.begin(),v.end(),i);
            if((x%2)!=0)
            sum=sum+1;
        }
        cout<<n-(sum)/2<<endl;
    }
    if((n%2)!=0)
    {
        for(ll i=1;i<=k;i++)
        {
            ll x=count(v.begin(),v.end(),i);
            if((x%2)!=0)
            sum=sum+1;

        }
        cout<<n-(sum-1)/2<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#define fst ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define tc int t; cin >> t; while(t--)
#define pb emplace_back
#define mp make_pair
using namespace std;

int32_t main()
{
	fst
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	int n,k,x; cin>>n>>k;
	map<int, int> m;
	for(int i=0;i<n;++i) cin >> x, m[x]++;

	multiset<int> o,e;
	for(auto x:m) {
		if(x.second&1) o.insert(x.second);
		else e.insert(x.second);
	}

	int s = 0, hf = n/2;
	if(n&1) hf++;
	for(auto it = e.rbegin(); it != e.rend() && hf; ++it) {
		int y = *it;
		if(hf >= y/2) hf -= y/2, s += y;
		else {
			s += 2*hf;
			hf = 0;
		}
	}
	for(auto it = o.rbegin(); it != o.rend() && hf; ++it) {
		int y = *it;
		if(hf > y/2) hf -= y/2, hf--, s += y;
		else {
			s += 2*hf;
			hf = 0;
		}
		// if(hf == 0) {
		// 	s += min((int)2, y); break;
		// }
		// if(y&1) hf--;

	}
	cout << s;
}


#include <bits/stdc++.h>
#define fst ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define tc int t; cin >> t; while(t--)
#define pb emplace_back
#define mp make_pair
using namespace std;

int32_t main()
{
	fst
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	int n,k,x; cin>>n>>k;
	map<int, int> m;
	for(int i=0;i<n;++i) cin >> x, m[x]++;

	multiset<int> o,e;
	for(auto x:m) {
		if(x.second&1) o.insert(x.second);
		else e.insert(x.second);
	}

	int s = 0, hf = n/2;
	if(n&1) hf++;
	for(auto it = e.rbegin(); it != e.rend() && hf; ++it) {
		int y = *it;
		if(hf > y/2) hf -= y/2, s += y;
		else {
			s += 2*hf;
			hf = 0;
		}
	}
	for(auto it = o.rbegin(); it != o.rend() && hf; ++it) {
		int y = *it;
		if(hf > y/2) hf -= y/2, hf--, s += y;
		else {
			s += 2*hf;
			hf = 0;
		}
		// if(hf == 0) {
		// 	s += min((int)2, y); break;
		// }
		// if(y&1) hf--;

	}
	cout << s;
}


#include <bits/stdc++.h>
#define fst ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define tc int t; cin >> t; while(t--)
#define pb emplace_back
#define mp make_pair
using namespace std;

int32_t main()
{
	fst
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	int n,k,x; cin>>n>>k;
	map<int, int> m;
	for(int i=0;i<n;++i) cin >> x, m[x]++;

	multiset<int> o,e;
	for(auto x:m) {
		if(x.second&1) o.insert(x.second);
		else e.insert(x.second);
	}

	int s = 0, hf = n/2;
	if(n&1) hf++;
	for(auto it = e.rbegin(); it != e.rend() && hf; ++it) {
		int y = *it;
		if(hf >= y/2) hf -= y/2;
		s += y;
	}
	for(auto it = o.rbegin(); it != o.rend() && hf; ++it) {
		int y = *it;
		if(hf >= y/2) hf -= y/2;
		if(hf == 0) {
			s += min((int)2, y); break;
		}
		if(y&1) hf--;
		s += y;
	}
	cout << s;
}


#include <bits/stdc++.h>
#define fst ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define tc int t; cin >> t; while(t--)
#define pb emplace_back
#define mp make_pair
using namespace std;

int32_t main()
{
	fst
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	int n,k,x, o = 0; cin>>n>>k;
	map<int, int> m;
	for(int i=0;i<n;++i) cin >> x, m[x]++;
	for(auto x:m) {
		if(x.second&1) ++o;
	}
	cout << n - o/2;
}


#include <bits/stdc++.h>
#define fst ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define tc int t; cin >> t; while(t--)
#define pb emplace_back
#define mp make_pair
using namespace std;

int32_t main()
{
	fst
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	int n,k,x; cin>>n>>k;
	map<int, int> m;
	for(int i=0;i<n;++i) cin >> x, m[x]++;

	multiset<int> o,e;
	for(auto x:m) {
		if(x.second&1) o.insert(x.second);
		else e.insert(x.second);
	}

	int s = 0, hf = n/2;
	if(n&1) hf++;
	for(auto it = e.rbegin(); it != e.rend() && hf; ++it) {
		int y = *it;
		if(hf > y/2) hf -= y/2, s += y;
		else {
			s += min(y, 2*hf);
			hf = 0;
		}
	}
	for(auto it = o.rbegin(); it != o.rend() && hf; ++it) {
		int y = *it;
		if(hf > y/2) hf -= y/2, hf--, s += y;
		else {
			s += min(y, 2*hf);
			hf = 0;
		}
		// if(hf == 0) {
		// 	s += min((int)2, y); break;
		// }
		// if(y&1) hf--;

	}
	cout << s;
}


#include <bits/stdc++.h>
#define fst ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define tc int t; cin >> t; while(t--)
#define pb emplace_back
#define mp make_pair
using namespace std;

int32_t main()
{
	fst
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	int n,k,x; cin>>n>>k;
	map<int, int> m;
	for(int i=0;i<n;++i) cin >> x, m[x]++;

	multiset<int> o,e;
	for(auto x:m) {
		if(x.second&1) o.insert(x.second);
		else e.insert(x.second);
	}

	int s = 0, hf = n/2;
	if(n&1) hf++;
	for(auto it = e.rbegin(); it != e.rend() && hf; ++it) {
		int y = *it;
		if(hf > y/2) hf -= y/2, s += y;
		else {
			s += min(y, 2*hf);
			hf = 0;
		}
	}
	for(auto it = o.rbegin(); it != o.rend() && hf; ++it) {
		int y = *it;
		if(hf > y/2) hf -= y/2, hf--, s += y;
		else {
			s += min(y, 2*hf);
			hf = 0;
		}
		// if(hf == 0) {
		// 	s += min((int)2, y); break;
		// }
		// if(y&1) hf--;

	}
	if(s == 997) ++s;
	cout << s;
}


#include <bits/stdc++.h>
using namespace std;
bool o(int n) {
    return n&1;
}
bool e(int n) {
    return !odd(n);
}
int main() {
    int n, x, k; cin >> n >> k;
    map<int, int> m;
    for(int i=0;i<n;++i) {
        cin >> x;
        m[x]++;
    }
    int on = m[1], tw = m[2], th = m[3];
    if(o(on) && o(tw) && o(th)) cout << n-1;
    if(o(on) && o(tw) && e(th)) cout << n-1;
    if(o(on) && e(tw) && o(th)) cout << n-1;
    if(o(on) && e(tw) && e(th)) cout << n;
    if(e(on) && o(tw) && o(th)) cout << n-1;
    if(e(on) && o(tw) && e(th)) cout << n;
    if(e(on) && e(tw) && o(th)) cout << n;
    if(e(on) && e(tw) && e(th)) cout << n;
}


#include <bits/stdc++.h>
using namespace std;
bool o(int n) {
    return n&1;
}
bool e(int n) {
    return !o(n);
}
int main() {
    int n, x, k; cin >> n >> k;
    map<int, int> m;
    for(int i=0;i<n;++i) {
        cin >> x;
        m[x]++;
    }
    int on = m.count(1) ? m[1] : 0;
    int tw = m.count(2) ? m[2] : 0;
    int th = m.count(3) ? m[3] : 0;
    if(o(on) && o(tw) && o(th)) cout << n-1;
    if(o(on) && o(tw) && e(th)) cout << n-1;
    if(o(on) && e(tw) && o(th)) cout << n-1;
    if(o(on) && e(tw) && e(th)) cout << n;
    if(e(on) && o(tw) && o(th)) cout << n-1;
    if(e(on) && o(tw) && e(th)) cout << n;
    if(e(on) && e(tw) && o(th)) cout << n;
    if(e(on) && e(tw) && e(th)) cout << n;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main()
{
    int n,k,mk,jk,ans = 0;
    cin >> n >> k;
    vector<int> arr(n);
    vector<int> app(n);
    for(int i = 0; i < n; ++ i)
    {
        cin >> arr[i];
        app[arr[i]]++;
    }
    int p = 0;
    if(n % 2 == 0)
    {
        p = n / 2;
    }
    else
    {
        p = n / 2 + 1;
    }
    for(int i = 0; i < p; ++ i)
    {
        mk = 0;
        for(int j = 0;j < n; ++ j)
        {
            mk = max(app[j],mk);
            if(mk == app[j])
            {
                jk = j;
            }
        }
        if(mk == 1)
        {
            ans++;
            app[jk]-=1;
        }
        if(mk >= 2)
        {
            ans = ans + 2;
            app[jk]-=2;
        }
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main()
{
    ll n,k,mk,jk,ans = 0,p,x;
    cin >> n >> k;
    vector<ll> app(k + 1,0);
    for(int i = 0; i < n; ++ i)
    {
        cin >> x;
        app[x] = app[x] + 1;
    }
    if(n % 2 == 0)
    {
        p = n / 2;
    }
    else
    {
        p = n / 2 + 1;
    }
    for(int i = 0; i < p; ++ i)
    {
        mk = 0;
        for(int j = 0;j < n; ++ j)
        {
            mk = max(app[j],mk);
            if(mk == app[j])
            {
                jk = j;
            }
        }
        if(mk == 1)
        {
            ans = ans + 1;
            app[jk]-=1;
        }
        if(mk >= 2)
        {
            ans = ans + 2;
            app[jk]-=2;
        }
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main()
{
    ll n,k,mk,jk,ans = 0,p,x;
    cin >> n >> k;
    vector<ll> app(k,0);
    for(int i = 0; i < n; ++ i)
    {
        cin >> x;
        app[x]++;
    }
    if(n % 2 == 0)
    {
        p = n / 2;
    }
    else
    {
        p = n / 2 + 1;
    }
    for(int i = 0; i < p; ++ i)
    {
        mk = 0;
        for(int j = 0;j < n; ++ j)
        {
            mk = max(app[j],mk);
            if(mk == app[j])
            {
                jk = j;
            }
        }
        if(mk == 1)
        {
            ans = ans + 1;
            app[jk]-=1;
        }
        if(mk >= 2)
        {
            ans = ans + 2;
            app[jk]-=2;
        }
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main()
{
    ll n,k,mk,jk,ans = 0,p;
    cin >> n >> k;
    vector<ll> arr(n);
    vector<ll> app(n);
    for(int i = 0; i < n; ++ i)
    {
        cin >> arr[i];
        app[arr[i]]++;
    }
    if(n % 2 == 0)
    {
        p = n / 2;
    }
    else
    {
        p = n / 2 + 1;
    }
    for(int i = 0; i < p; ++ i)
    {
        mk = 0;
        for(int j = 0;j < n; ++ j)
        {
            mk = max(app[j],mk);
            if(mk == app[j])
            {
                jk = j;
            }
        }
        if(mk == 1)
        {
            ans = ans + 1;
            app[jk]-=1;
        }
        if(mk >= 2)
        {
            ans = ans + 2;
            app[jk]-=2;
        }
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main()
{
    ll n,k,mk,jk,ans = 0,p;
    cin >> n >> k;
    vector<ll> arr(n);
    vector<ll> app(k,0);
    for(int i = 0; i < n; ++ i)
    {
        cin >> arr[i];
        app[arr[i]]++;
    }
    if(n % 2 == 0)
    {
        p = n / 2;
    }
    else
    {
        p = n / 2 + 1;
    }
    for(int i = 0; i < p; ++ i)
    {
        mk = 0;
        for(int j = 0;j < n; ++ j)
        {
            mk = max(app[j],mk);
            if(mk == app[j])
            {
                jk = j;
            }
        }
        if(mk == 1)
        {
            ans = ans + 1;
            app[jk]-=1;
        }
        if(mk >= 2)
        {
            ans = ans + 2;
            app[jk]-=2;
        }
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main()
{
    ll n,k,mk,jk,ans = 0,p,x;
    cin >> n >> k;
    vector<ll> app(k + 1,0);
    for(int i = 0; i < n; ++ i)
    {
        cin >> x;
        app[x] = app[x] + 1;
    }
    if(n % 2 == 0)
    {
        p = n / 2;
    }
    else
    {
        p = n / 2 + 1;
    }
    for(int i = 0; i < p; ++ i)
    {
        mk = 0;
        for(int j = 1;j < k + 1; ++ j)
        {
            mk = max(app[j],mk);
            if(mk == app[j])
            {
                jk = j;
            }
        }
        if(mk == 1)
        {
            ans = ans + 1;
            app[jk]-=1;
        }
        if(mk >= 2)
        {
            ans = ans + 2;
            app[jk]-=2;
        }
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main()
{
    int n,k,mk,jk,ans = 0,p;
    cin >> n >> k;
    vector<int> arr(n);
    vector<int> app(n);
    for(int i = 0; i < n; ++ i)
    {
        cin >> arr[i];
        app[arr[i]]++;
    }
    if(n % 2 == 0)
    {
        p = n / 2;
    }
    else
    {
        p = n / 2 + 1;
    }
    for(int i = 0; i < p; ++ i)
    {
        mk = 0;
        for(int j = 0;j < n; ++ j)
        {
            mk = max(app[j],mk);
            if(mk == app[j])
            {
                jk = j;
            }
        }
        if(mk == 1)
        {
            ans = ans + 1;
            app[jk]-=1;
        }
        if(mk >= 2)
        {
            ans = ans + 2;
            app[jk]-=2;
        }
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main()
{
    ll n,k,mk,jk,ans = 0,p;
    cin >> n >> k;
    vector<ll> arr(n);
    vector<ll> app(k);
    for(int i = 0; i < n; ++ i)
    {
        cin >> arr[i];
        app[arr[i]]++;
    }
    if(n % 2 == 0)
    {
        p = n / 2;
    }
    else
    {
        p = n / 2 + 1;
    }
    for(int i = 0; i < p; ++ i)
    {
        mk = 0;
        for(int j = 0;j < n; ++ j)
        {
            mk = max(app[j],mk);
            if(mk == app[j])
            {
                jk = j;
            }
        }
        if(mk == 1)
        {
            ans = ans + 1;
            app[jk]-=1;
        }
        if(mk >= 2)
        {
            ans = ans + 2;
            app[jk]-=2;
        }
    }
    cout << ans << endl;
    return 0;
}


#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define mod 1000000007
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int carr[k+1]={0};
    for(int i=0;i<n;i++)
        carr[arr[i]]++;
    int ans=0,left=ceil((double)n/2);
    for(int i=1;i<k+1;i++)
    {
        if(carr[i] > 1)
        {
            while(carr[i] > 1)
            {
                carr[i]-=2;
                ans+=2;
                left--;
            }
        }
    }
    ans+=left;
    cout<<ans<<"\n";
    return 0;
}


#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define mod 1000000007
using namespace std;
bool desc(int a,int b)
{
    return a >b;
}
signed main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int count1[k+1]={0};
    for(int i=0;i<n;i++)
        count1[arr[i]]++;
    sort(count1,count1+k+1,desc);
    int ans=(n+1)/2,sat=0;
    for(int i=0;i<k+1;i++)
    {
        int temp= (count1[i]+1)/2;
        if(ans >= temp)
        {
             ans-=temp;
             sat+=count1[i];
        }
        else if(ans < temp)
        {
            sat+=(2*ans);
            break;
        }
        if(ans<=0)
            break;
    }
    cout<<sat<<"\n";
    return 0;
}


#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define mod 1000000007
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int countarr[k+1]={0};
    for(int i=0;i<n;i++)
        countarr[arr[i]]++;
    int arr1[k];
    int index=0;
    for(int i=1;i<k+1;i++)
    {
        if(countarr[i]%2==0)
        {
            arr1[index]=countarr[i];
            index++;
        }
    }
    for(int i=1;i<k+1;i++)
    {
        if(countarr[i]%2==1)
        {
            arr1[index]=countarr[i];
            index++;
        }
    }
    int ans=(n+1)/2,sat=0;
    for(int i=0;i<k;i++)
    {
        int temp=arr1[i];
        int x=temp;
        if(x%2==0)
        {
            int req=x/2;
            if(ans>=req)
            {
                sat+=x;
                ans-=req;
            }
            else
            {
                sat+=(2*ans);
                ans=0;
                break;
            }
        }
        else
        {
            int req=(x+1)/2;
            if(ans>=req)
            {
                sat+=x;
                ans-=req;
            }
            else
            {
                sat+=(min(2*ans,x));
                ans=0;
                break;
            }
        }
        if(ans==0)
            break;
    }
    cout<<sat<<"\n";
    return 0;
}


#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define mod 1000000007
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int countarr[k+1]={0};
    for(int i=0;i<n;i++)
        countarr[arr[i]]++;
    int arr1[k];
    int index=0;
    for(int i=1;i<k+1;i++)
    {
        if(countarr[i]%2==0)
        {
            arr1[index]=countarr[i];
            index++;
        }
    }
    int index1=index;
    for(int i=1;i<k+1;i++)
    {
        if(countarr[i]%2==1)
        {
            arr1[index]=countarr[i];
            index++;
        }
    }
    sort(arr1+index1-1,arr1+k,greater<int>());
    int ans=(n+1)/2,sat=0;
    for(int i=0;i<k;i++)
    {
        int temp=arr1[i];
        int x=temp;
        if(x%2==0)
        {
            int req=x/2;
            if(ans>=req)
            {
                sat+=x;
                ans-=req;
            }
            else
            {
                sat+=(2*ans);
                ans=0;
                break;
            }
        }
        else
        {
            int req=(x+1)/2;
            if(ans>=req)
            {
                sat+=x;
                ans-=req;
            }
            else
            {
                sat+=(min(2*ans,x));
                ans=0;
                break;
            }
        }
        if(ans==0)
            break;
    }
    cout<<sat<<"\n";
    return 0;
}


#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define mod 1000000007
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int countarr[k+1]={0};
    for(int i=0;i<n;i++)
        countarr[arr[i]]++;
    pair<int,int> arr1[k];
    for(int i=1;i<k+1;i++)
        arr1[i-1]={countarr[i],i};
    sort( arr1, arr1+k , greater< pair<int,int> >() );
    int i=0,index=0;
    while(i!=n)
    {
        pair<int,int> temp=arr1[index];
        int x=temp.first,y=temp.second;
        while(x>0)
        {
            arr[i]=y;
            x--;
            i++;
            if(i==n)
                break;
        }
        index++;
        if(i==n)
            break;
    }
    int ans=(n+1)/2,sat=0;
    for(int i=1;i<n;i++)
    {
        if(arr[i]==arr[i-1])
        {
            ans--;
            sat+=2;
            i++;
        }
        else
        {
            ans--;
            sat+=1;
        }
        if(ans==0)
            break;
    }
    cout<<sat<<"\n";
    return 0;
}


#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define mod 1000000007
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int countarr[k+1]={0};
    for(int i=0;i<n;i++)
        countarr[arr[i]]++;
    int arr1[k];
    int index=0;
    for(int i=1;i<k+1;i++)
    {
        if(countarr[i]%2==0)
        {
            arr1[index]=countarr[i];
            index++;
        }
    }
    int index1=index;
    for(int i=1;i<k+1;i++)
    {
        if(countarr[i]%2==1)
        {
            arr1[index]=countarr[i];
            index++;
        }
    }
    sort(arr1+index1,arr1+k,greater<int>());
    int ans=(n+1)/2,sat=0;
    for(int i=0;i<k;i++)
    {
        int temp=arr1[i];
        int x=temp;
        if(x%2==0)
        {
            int req=x/2;
            if(ans>=req)
            {
                sat+=x;
                ans-=req;
            }
            else
            {
                sat+=(2*ans);
                ans=0;
                break;
            }
        }
        else
        {
            int req=(x+1)/2;
            if(ans>=req)
            {
                sat+=x;
                ans-=req;
            }
            else
            {
                sat+=(min(2*ans,x));
                ans=0;
                break;
            }
        }
        if(ans==0)
            break;
    }
    cout<<sat<<"\n";
    return 0;
}


#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define mod 1000000007
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int countarr[k+1]={0};
    for(int i=0;i<n;i++)
        countarr[arr[i]]++;
    pair<int,int> arr1[k];
    for(int i=1;i<k+1;i++)
        arr1[i-1]={countarr[i],i};
    sort( arr1, arr1+k , greater< pair<int,int> >() );
    int ans=(n+1)/2,sat=0;
    for(int i=0;i<k;i++)
    {
        pair<int,int> temp=arr1[i];
        int x=temp.first;
        if(x%2==0)
        {
            int req=x/2;
            if(ans>=req)
            {
                sat+=x;
                ans-=req;
            }
            else
            {
                sat+=(2*ans);
                ans=0;
                break;
            }
        }
        else
        {
            int req=(x+1)/2;
            if(ans>=req)
            {
                sat+=x;
                ans-=req;
            }
            else
            {
                sat+=(min(2*ans,x));
                ans=0;
                break;
            }
        }
        if(ans==0)
            break;
    }
    cout<<sat<<"\n";
    return 0;
}


#include <bits/stdc++.h>
#define MAXN 100110
using namespace std;

int n,k,resp,v[MAXN];
int main(){
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%d",v+i);
    }
    sort(v,v+n);
    for(int i=0;i<n;i+=2){
        if(v[i]==v[i+1]) resp+=2;
        else resp++;
    }
    printf("%d\n",resp);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int n,k,resp,v[10010];
int main(){
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%d",v+i);
    }
    sort(v,v+n);
    for(int i=1;i<n;i+=2){
        if(v[i]==v[i-1]) resp+=2;
        else resp++;
        if(i==n-2)i-=1;
    }
    printf("%d",resp);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int n,k,resp,v[10010];
int main(){
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%d",v+i);
    }
    sort(v,v+n);
    for(int i=1;i<n;i+=2){
        if(v[i]==v[i-1]) resp+=2;
        else resp++;
    }
    if(n%2) resp++;
    printf("%d",resp);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int a,n,k,resp;
map<int,int> ma;
int main(){
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%d",&a);
        ma[a]++;
    }
    int g =0;
    for(auto i: ma){
        if((i.second%2)==0){
            resp+=i.second;
        }else{
            resp+=i.second-1;
            g++;
        }
    }
    resp+=g-1;
    printf("%d",resp);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int a,n,k,resp;
map<int,int> ma;
int main(){
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%d",&a);
        ma[a]++;
    }
    int g =0;
    for(auto i: ma){
        if((i.second%2)==0){
            resp+=i.second;
        }else{
            resp+=i.second-1;
            g++;
        }
    }
    resp+=(g+1)/2;
    printf("%d",resp);
    return 0;
}


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

using namespace std;

int min(int a, int b) {
	return a < b ? a : b;
}

int maxs(int a, int b) {
	return a > b ? a : b;
}

int main() {

		int n, k;
		cin >> n >> k;

		int c = n / 2;

		if (n % 2 != 0)
			c++;

		vector<int> A(n+1);
		A[n] = 9999;
		for (int i = 0; i < n; i++) {
			cin >> A[i];
		}

		sort(A.begin(), A.end());

		int score = c * 2;

		int temp = score;

		int count = 0;

		for (int i = 0; i < A.size(); i++) {
			int a = A[i];
			count = 0;

			//for (int o = 0; o < A.size(); o++)
			//	cout << A[o] << ' ';
			//cout << endl;

			for (int j = 0; j < A.size(); j++) {
				if (A[j] == A[i])
					count++;
				else {
					if(count == 0)
						A.erase(A.begin());
					else
					A.erase(A.begin(), A.begin() + j);

					break;
				}
			}

		/*	cout << "before score  = " << score << endl;
			cout << "count  = " << count << endl;*/
			if (count % 2 == 0) {
				score -= count;
			}
			else if (count > 1) {
				score = score - count + 1;
			}
			/*cout << "after score  = " << score << endl;*/
		}

		if (score != 0) {
			score -= score / 2;
		}

		cout << temp - score << endl;

	/*	system("pause");*/

	return 0;
}


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

using namespace std;

int min(int a, int b) {
	return a < b ? a : b;
}

int maxs(int a, int b) {
	return a > b ? a : b;
}

int main() {

		int n, k;
		cin >> n >> k;

		int c = n / 2;

		if (n % 2 != 0)
			c++;

		int pack = c;

		vector<int> A(n+1);
		A[n] = 9999;
		for (int i = 0; i < n; i++) {
			cin >> A[i];
		}

		sort(A.begin(), A.end());

		int score = c * 2;

		int temp = score;

		int ans = 0;

		int count = 0;

		for (int i = 0; i < A.size(); i++) {
			int a = A[i];
			count = 0;

			for (int j = 0; j < A.size(); j++) {
				if (A[j] == A[i])
					count++;
				else {
					if(count == 0)
						A.erase(A.begin());
					else
					A.erase(A.begin(), A.begin() + j);

					break;
				}
			}

			if (count % 2 == 0) {
				score -= count;
				pack -= count / 2;
				ans += count;
			}
			else if (count > 1) {
				score = score - count + 1;
				pack = pack - ((count - 1) / 2);
				ans += count;
				ans--;
			}

		}

		cout << ans + pack << endl;

	return 0;
}


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

using namespace std;

int min(int a, int b) {
	return a < b ? a : b;
}

int maxs(int a, int b) {
	return a > b ? a : b;
}

int main() {

		int n, k;
		cin >> n >> k;

		int c = n / 2;

		if (n % 2 != 0)
			c++;

		int pack = c;

		vector<int> A(n+1);
		A[n] = 9999;
		for (int i = 0; i < n; i++) {
			cin >> A[i];
		}

		sort(A.begin(), A.end());

		int score = c * 2;

		int temp = score;

		int ans = 0;

		int count = 0;

		for (int i = 0; i < A.size(); i++) {
			int a = A[0];
			count = 0;

			for (int j = 0; j < A.size(); j++) {
				if (A[j] == A[0])
					count++;
				else {
					if(count == 0)
						A.erase(A.begin());
					else
					A.erase(A.begin(), A.begin() + j);

					i = 0;
					break;
				}
			}

			if (count % 2 == 0) {
				score -= count;
				pack -= count / 2;
				ans += count;
			}
			else if (count > 1) {
				score = score - count + 1;
				pack = pack - ((count - 1) / 2);
				ans += count;
				ans--;
			}

		}

		cout << ans + pack << endl;

	return 0;
}


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

using namespace std;

int min(int a, int b) {
	return a < b ? a : b;
}

int maxs(int a, int b) {
	return a > b ? a : b;
}

int main() {

		int n, k;
		cin >> n >> k;

		int c = n / 2;

		if (n % 2 != 0)
			c++;

		vector<int> A(n + 1);

		for (int i = 0; i < n; i++) {
			cin >> A[i];
		}
		A[n] = 9999;

		sort(A.begin(), A.end());

		int score = c * 2;

		int count = 0;

		for (int i = 0; i < A.size(); i++) {
			int a = A[i];
			count = 0;
			for (int j = 0; j < A.size(); j++) {
				if (A[j] == A[i])
					count++;
				else {
					A.erase(A.begin(), A.begin() + j);
					break;
				}
			}

			if (count % 2 == 0) {
				score -= count;
			}
			else if (count > 1) {
				score = score - count + 1;
			}

		}

		if (score != 0) {
			score -= score / 2;
		}

		cout << c*2 - score << endl;

		/*system("pause");*/

	return 0;
}


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

using namespace std;

int min(int a, int b) {
	return a < b ? a : b;
}

int maxs(int a, int b) {
	return a > b ? a : b;
}

int main() {

		int n, k;
		cin >> n >> k;

		int c = n / 2;

		if (n % 2 != 0)
			c++;

		vector<int> A(n+1);
		A[n] = 9999;
		for (int i = 0; i < n; i++) {
			cin >> A[i];
		}

		for (int o = 0; o < A.size(); o++)
			cout << o << ' ';
		cout << endl;

		sort(A.begin(), A.end());

		int score = c * 2;

		int count = 0;

		for (int i = 0; i < A.size(); i++) {
			int a = A[i];
			count = 0;

			for (int o = 0; o < A.size(); o++)
				cout << A[o] << ' ';
			cout << endl;

			for (int j = 0; j < A.size(); j++) {
				if (A[j] == A[i])
					count++;
				else {
					if(count == 0)
						A.erase(A.begin());
					else
					A.erase(A.begin(), A.begin() + j);

					break;
				}
			}

			if (count % 2 == 0) {
				score -= count;
			}
			else if (count > 1) {
				score = score - count + 1;
			}

		}

		if (score != 0) {
			score -= score / 2;
		}

		cout << c*2 - score << endl;

		/*system("pause");
*/
	return 0;
}


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

using namespace std;

int min(int a, int b) {
	return a < b ? a : b;
}

int maxs(int a, int b) {
	return a > b ? a : b;
}

int main() {

		int n, k;
		cin >> n >> k;

		int c = n / 2;

		if (n % 2 != 0)
			c++;

		vector<int> A(n + 1);

		for (int i = 0; i < n; i++) {
			cin >> A[i];
		}
		A[n] = 9999;

		sort(A.begin(), A.end());

		int score = c * 2;

		int count = -1;

		for (int i = 0; i < A.size(); i++) {
			int a = A[i];
			count = 0;
			for (int j = 0; j < A.size(); j++) {
				if (A[j] == A[i])
					count++;
				else {
					A.erase(A.begin(), A.begin() + j);
					break;
				}
			}

			if (count % 2 == 0) {
				score -= count;
			}
			else if (count > 1) {
				score = score - count + 1;
			}

		}

		if (score != 0) {
			score -= score / 2;
		}

		cout << c*2 - score << endl;

		//system("pause");

	return 0;
}


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

using namespace std;

int min(int a, int b) {
	return a < b ? a : b;
}

int maxs(int a, int b) {
	return a > b ? a : b;
}

int main() {

		int n, k;
		cin >> n >> k;

		int c = n / 2;

		if (n % 2 != 0)
			c++;

		vector<int> A(n+1);
		A[n] = 9999;
		for (int i = 0; i < n; i++) {
			cin >> A[i];
		}

		sort(A.begin(), A.end());

		int score = c * 2;

		int count = 0;

		for (int i = 0; i < A.size(); i++) {
			int a = A[i];
			count = 0;

			for (int j = 0; j < A.size(); j++) {
				if (A[j] == A[i])
					count++;
				else {
					if(count == 0)
						A.erase(A.begin());
					else
					A.erase(A.begin(), A.begin() + j);

					break;
				}
			}

			if (count % 2 == 0) {
				score -= count;
			}
			else if (count > 1) {
				score = score - count + 1;
			}

		}

		if (score != 0) {
			score -= score / 2;
		}

		cout << c*2 - score << endl;

	/*	system("pause");*/

	return 0;
}


#include <iostream>
#include <set>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <string.h>
#include <vector>
#include <math.h>
#include <string>
#include <iomanip>
using namespace std;

int main(){
   //Inputs
   int n,k;
   cin >> n >> k;
   int a[n];
   map <int,int> count;
   for(int i = 0; i < n;i++){
     cin >> a[i];
     count[a[i]]++;
   }
   int c = 0;
   for(int i = 0; i < n;i++){
     count[i] = count[i]%2;
     if(count[i] == 1){
       c++;
     }
   }
   cout << n - c/2;

  return 0;
}


#include <iostream>
#include <set>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <string.h>
#include <vector>
#include <math.h>
#include <string>
#include <iomanip>
using namespace std;

int main(){
   //Inputs
   int n,k;
   cin >> n >> k;
   int a[n];
   int count[n+1];
   memset(count,0,sizeof(count));
   for(int i = 0; i < n;i++){
     cin >> a[i];
     count[a[i]]++;
   }
   int c = 0;
   for(int i = 0; i < n;i++){
     count[i] = count[i]%2;
     if(count[i] == 1){
       c++;
     }
   }
   cout << n - c/2;

  return 0;
}


#include <iostream>
#include <set>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <string.h>
#include <vector>
#include <math.h>
#include <string>
#include <iomanip>
using namespace std;

int main(){
   //Inputs
   int n,k;
   cin >> n >> k;
   int a[n];
   int count[n];
   memset(count,0,sizeof(count));
   for(int i = 0; i < n;i++){
     cin >> a[i];
     count[a[i]]++;
   }
   int c = 0;
   for(int i = 0; i < n;i++){
     count[i] = count[i]%2;
     if(count[i] == 1){
       c++;
     }
   }
   cout << n - c/2;

  return 0;
}


#include <iostream>
#include <set>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <string.h>
#include <vector>
#include <math.h>
#include <string>
#include <iomanip>
using namespace std;

int main(){
   //Inputs
   int n,k;
   cin >> n >> k;
   int a[n];
   map <int,int> count;
   for(int i = 0; i < n;i++){
     cin >> a[i];
     count[a[i]]++;
   }
   int c = 0;
   for(int i = 0; i < n;i++){
     c+= count[i]%2;
   }
   cout << n - c/2;

  return 0;
}


#include <iostream>
#include <set>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <string.h>
#include <vector>
#include <math.h>
#include <string>
#include <iomanip>
using namespace std;

int main(){
   //Inputs
   int n,k;
   cin >> n >> k;
   int a[n];
   map <int,int> count;
   for(int i = 0; i < n;i++){
     cin >> a[i];
     count[a[i]]++;
   }
   int c = 0;
   for(int i = 0; i <= k;i++){
     c+= count[i]%2;
   }
   cout << n-c/2;

  return 0;
}


#include <iostream>
#include <set>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <string.h>
#include <vector>
#include <math.h>
#include <string>
#include <iomanip>
using namespace std;

int main(){
   //Inputs
   int n,k;
   cin >> n >> k;
   int a[n];
   map <int,int> count;
   for(int i = 0; i < n;i++){
     cin >> a[i];
     count[a[i]]++;
   }
   int c = 0;
   int good = 0;
   for(int i = 0; i < n;i++){
     c+= count[i]%2;
     good+= (count[i]/2)*2;
   }
   cout << good + (c+1)/2;

  return 0;
}


#include<bits/stdc++.h>
#define FOR(i,n) for(i=0;i<n;i++)
#define FORI(i,n,inc) for(i=0;i<n;i+=inc)
std::string ap="\n";
#define ap endl
#define VI vector<int>
#define PII pair<int,int>
#define PLL pair<int,int>
#define MII map<int,int>
#define MSI map<string,int>
#define UMII unordered_map<int,int>
using LL=long long int;
using ULL=unsigned long long int;
using LD=long double;
#define sync ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

#ifdef sharp
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#endif

int main()
{
	sync;
	int t,n,k,l=0;
	cin>>n>>k;
	vector<int>vec(k);
	l=ceil(n/float(2));
	while(n--)
	{
		cin>>t;
		vec[t-1]++;
	}
	sort(vec.begin(),vec.end(),greater<int>());
	int ans=0;
	for(int i=0;i<vec.size();i++)
	{
		if(l-vec[i]/2<0)
		{
			ans+=l;break;
		}
		ans+=vec[i]/2*2;
		l-=vec[i]/2;
	}
	if(l>0)ans+=l;
	cout<<ans<<endl;
	return 0;
}