#include<stdio.h>
#include<string.h>
int dp[1002][32],num[1002];
int max(int a,int b)
{
return a>b?a:b;
}
#include<string.h>
int dp[1002][32],num[1002];
int max(int a,int b)
{
return a>b?a:b;
}
int main()
{
int T,W,i,j,ans;
scanf("%d%d",&T,&W);
for(i = 1;i <= T;++i) scanf("&d",&num[i]);
if(num[1]&1) dp[1][0] = 1;
ans = dp[1][1] = 1;
for(i = 2;i <= T;++i)
{
dp[i][j] = dp[i-1][0] + (num[i]&1);
for(j = 1;j <= T;++j)
{
dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
dp[i][j] += ((j + num[i])&1);
ans = max(ans,dp[i][j]);
}
}
printf("%d\n",ans);
return 0;
}
{
int T,W,i,j,ans;
scanf("%d%d",&T,&W);
for(i = 1;i <= T;++i) scanf("&d",&num[i]);
if(num[1]&1) dp[1][0] = 1;
ans = dp[1][1] = 1;
for(i = 2;i <= T;++i)
{
dp[i][j] = dp[i-1][0] + (num[i]&1);
for(j = 1;j <= T;++j)
{
dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
dp[i][j] += ((j + num[i])&1);
ans = max(ans,dp[i][j]);
}
}
printf("%d\n",ans);
return 0;
}