M. The Pleasant Walk

There are nn houses along the road where Anya lives, each one is painted in one of kk possible colors.

Anya likes walking along this road, but she doesn't like when two adjacent houses at the road have the same color. She wants to select a long segment of the road such that no two adjacent houses have the same color.

Help Anya find the longest segment with this property.

Input

The first line contains two integers nn and kk — the number of houses and the number of colors (1≤n≤1000001≤n≤100000, 1≤k≤1000001≤k≤100000).

The next line contains nn integers a1,a2,…,ana1,a2,…,an — the colors of the houses along the road (1≤ai≤k1≤ai≤k).

Output

Output a single integer — the maximum number of houses on the road segment having no two adjacent houses of the same color.

Example

input

8 3
1 2 3 3 2 1 2 2

output

4

题意:Anya沿着一条公路走下去,路边的每个房子都有一种颜色,求最长的相邻房子颜色不一样的长度。

 

注意只有一所房子时输出1即可。

代码:

#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define mem(a,b) memset(a,b,sizeof(a))
#define closeio std::ios::sync_with_stdio(false)
 
int a[100005];
 
int main()
{
	int n,m,i,tmp,Max=-1;
	cin>>n>>m;
	for(i=0;i<n;i++)
		cin>>a[i];
	if(n==1)
	{
		cout<<1<<endl; 
		return 0;
	}
	tmp=1;
	for(i=0;i<n-1;i++)
	{
		if(a[i]!=a[i+1])
			tmp++;
		else
			tmp=1;
		Max=max(Max,tmp);
	}
	cout<<Max<<endl;
	return 0;
}