#include<bits/stdc++.h>
using namespace std;
const int mxmx=1e5+10,inf=1e9;

#define mp make_pair

int n,m;
vector<int>adj[mxmx];
int dp[mxmx];
vector<pair<int,int> >poop;
void bfs(int ver){
	poop.clear();
	poop.push_back(mp(ver,0));
	int v,next,fasele;
	for(int i=0;i<poop.size();i++){
		v=poop[i].first;
		fasele=poop[i].second;
		for(int j=0;j<adj[v].size();j++){
			next=adj[v][j];
			if(dp[next]>fasele+1){
				dp[next]=fasele+1;
				poop.push_back(mp(next,fasele+1));
			}
		}
	}
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	cin>>n>>m;
	for(int i=0;i<n;i++)dp[i]=inf;
	for(int i=1,a,b;i<n;i++){
		cin>>a>>b;
		a--;
		b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	dp[0]=0;
	bfs(0);
	for(int i=0,a,b;i<m;i++){
		cin>>a>>b;
		b--;
		if(a==1){
			bfs(b);
		}
		else{
			cout<<dp[b]<<endl;
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
const int mxmx=1e5+1,lgn=17,V_=77,inf=1e9+10;

#define mp make_pair
#define X first
#define Y second

//MAIN
int n,m;
vector<int>adj[mxmx];
vector<pair<int,int> >red;
int dp[mxmx];
//LCA
int par[lgn][mxmx];
int h[mxmx];
//ANS
int ANS;
int lca;

inline void pre(){
	fill(dp,dp+mxmx,inf);
	for(int i=0;i<mxmx;i++){
		for(int j=0;j<lgn;j++){
			par[j][i]=-1;
		}
	}
}

inline void multi_bfs(){
	int ver,next,dist;
	for(int i=0;i<red.size();i++){
		ver=red[i].X;
		dist=red[i].Y;
		if(dp[ver]<=dist)continue;
		dp[ver]=dist;
		for(int j=0;j<adj[ver].size();j++){
			next=adj[ver][j];
			red.push_back(mp(next,dist+1));
		}
	}
}

inline void pre_dfs(int ver,int H){
	int next;
	h[ver]=H;
	for(int i=1;i<lgn;i++){
		if(par[i-1][ver]!=-1)par[i][ver]=par[i-1][par[i-1][ver]];
		else par[i][ver]=-1;
	}
	for(int i=0;i<adj[ver].size();i++){
		next=adj[ver][i];
		if(next!=par[0][ver]){
			par[0][next]=ver;
			pre_dfs(next,H+1);
		}
	}
}

inline int LCA(int a,int b){
	int ret;
	ret=h[a]+h[b];
	if(h[a]<h[b])swap(a,b);
	for(int i=lgn-1;i>=0;i--){
		if(par[i][a]!=-1&&h[par[i][a]]>=h[b]){
			a=par[i][a];
		}
	}
	if(a!=b){
		for(int i=lgn-1;i>=0;i--){
			if(par[i][a]!=par[i][b]){
				a=par[i][a];
				b=par[i][b];
			}
		}
		a=par[0][a];
		b=par[0][b];
	}
	ret-=2*h[a];
	return ret;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	pre();
	scanf("%d %d",&n,&m);
	for(int i=1,a,b;i<n;i++){
		scanf("%d %d",&a,&b);
		a--;
		b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	pre_dfs(0,0);
	red.push_back(mp(0,0));
	for(int i=0,a,b;i<m;i++){
		scanf("%d %d",&a,&b);
		b--;

		if(a==1){
			red.push_back(mp(b,0));
			if(red.size()==V_){
				multi_bfs();
				red.clear();
			}
		}
		else{
			ANS=dp[b];
			for(int j=0;j<red.size();j++){
				lca=LCA(red[j].first,b);
				ANS=min(ANS,lca);
			}
			printf("%d\n",ANS);
		}
	}
	if(1==1){
		n=1;
		n=2
	}
}


#include<bits/stdc++.h>
using namespace std;
const int mxmx=1e5+10,lgn=20;

#define mp make_pair

int n,m;
vector <int>adj[mxmx];
struct vertex{
	int moalefe;
	int start_t,end_t;//
	int start,end;
	int dp;//
	int h;//
	int par[lgn];//
	vertex(){
		for(int i=0;i<lgn;i++)par[i]=-1;
	}
};
struct moalefe_b{
	int baba;
};
moalefe_b l[mxmx];
vertex ver[mxmx];
int moal=0,TIME=0;
vector<pair<int,int> >poop;
void dfs(int v){
	int next;
	ver[v].start_t=TIME;
	ver[v].start=poop.size();
	poop.push_back(mp(TIME,v));
	TIME++;
	for(int i=1;i<lgn;i++){
		if(ver[v].par[i-1]!=-1)ver[v].par[i]=ver[ver[v].par[i-1]].par[i-1];
		else ver[v].par[i]=-1;
	}
	for(int i=0;i<adj[v].size();i++){
		next=adj[v][i];
		if(next!=ver[v].par[0]){
			ver[next].h=ver[v].h+1;
			ver[next].par[0]=v;
			dfs(next);
			TIME++;
			ver[v].dp+=ver[next].dp;
		}
	}
	ver[v].dp++;
	ver[v].end_t=TIME;
	ver[v].end=poop.size();
	poop.push_back(mp(TIME,v));
}
int LCA(int a,int b){
	if(ver[a].h<ver[b].h)swap(a,b);
	while(ver[a].h>ver[b].h){
		for(int i=lgn-1;i>=0;i--){
			if(ver[a].par[i]!=-1){
				if(ver[ver[a].par[i]].h>=ver[b].h){
					a=ver[a].par[i];
					break;
				}
			}
		}
	}
	while(a!=b){
		for(int i=lgn-1;i>=0;i--){
			if(ver[a].par[i]!=-1){
				if(ver[a].par[i]!=ver[b].par[i]){
					a=ver[a].par[i];
					b=ver[b].par[i];
				}
			}
		}
	}
	if(a!=b){
		a=ver[a].par[0];
	}
	return a;
}
int test(int fasele,int a){
	int b=ver[a].h-fasele;
	while(ver[a].h!=b){
		for(int i=lgn-1;i>=0;i--){
			if(ver[a].par[i]!=-1){
				if(ver[ver[a].par[i]].h>=b){
					a=ver[a].par[i];
				}
			}
		}
	}
	return a;
}
void unmerge(int mid,int b,int baba,int lca){
	int dp1,dp2;
	dp1=ver[mid].dp;
	dp2=ver[lca].dp-dp1;
	for(int i=ver[b].start;i!=ver[b].end;i++){
		if(ver[poop[i].second].moalefe==ver[baba].moalefe)ver[poop[i].second].moalefe=moal;
	}
	l[moal].baba=b;
	moal++;
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>m;
	for(int i=1,u,v;i<n;i++){
		cin>>u>>v;
		u--;
		v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for(int i=0;i<n;i++){
		ver[i].moalefe=moal;
	}
	l[moal].baba=0;
	moal++;
	dfs(0);
	/*for(int i=0;i<n;i++){
		cout<<i+1<<endl;
		cout<<"moalefe"<<" "<<ver[i].moalefe<<endl;
		cout<<"TIME: "<<ver[i].start_t<<" "<<ver[i].end_t<<endl;
		cout<<"dp "<<ver[i].dp<<endl;
		cout<<"h "<<ver[i].h<<endl;
		cout<<"par"<<endl;
		for(int j=0;j<lgn;j++){
			cout<<j<<" ";
		}
		cout<<endl;
		for(int j=0;j<lgn;j++){
			cout<<ver[i].par[j]+1<<" ";
		}
		cout<<endl;
		cout<<"-----------------"<<endl;
	}*/
	int lca,baba,fasele,mid;
	for(int i=0,a,b;i<m;i++){
		cin>>a>>b;
		b--;
		if(a==2){
			baba=l[ver[b].moalefe].baba;
			lca=LCA(b,baba);
			fasele=ver[b].h-ver[lca].h+ver[baba].h-ver[lca].h;
			cout<<fasele<<endl;
		}
		else{
			baba=l[ver[b].moalefe].baba;
			lca=LCA(b,baba);
			fasele=ver[b].h-ver[lca].h+ver[baba].h-ver[lca].h;
			fasele/=2;
			mid=test(fasele,b);
			unmerge(mid,b,baba,lca);
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
const int mxmx=1e5+1,lgn=17,V_=77,inf=1e9+10;

#define mp make_pair
#define X first
#define Y second

//MAIN
int n,m;
vector<int>adj[mxmx];
vector<pair<int,int> >red;
int dp[mxmx];
//LCA
int par[lgn][mxmx];
int h[mxmx];
//ANS
int ANS;
int lca;

inline void pre(){
	fill(dp,dp+mxmx,inf);
	for(int i=0;i<mxmx;i++){
		for(int j=0;j<lgn;j++){
			par[j][i]=-1;
		}
	}
}

inline void multi_bfs(){
	int ver,next,dist;
	for(int i=0;i<red.size();i++){
		ver=red[i].X;
		dist=red[i].Y;
		if(dp[ver]<=dist)continue;
		dp[ver]=dist;
		for(int j=0;j<adj[ver].size();j++){
			next=adj[ver][j];
			red.push_back(mp(next,dist+1));
		}
	}
}

inline void pre_dfs(int ver,int H){
	int next;
	h[ver]=H;
	for(int i=1;i<lgn;i++){
		if(par[i-1][ver]!=-1)par[i][ver]=par[i-1][par[i-1][ver]];
		else par[i][ver]=-1;
	}
	for(int i=0;i<adj[ver].size();i++){
		next=adj[ver][i];
		if(next!=par[0][ver]){
			par[0][next]=ver;
			pre_dfs(next,H+1);
		}
	}
}

inline int LCA(int a,int b){
	int ret;
	ret=h[a]+h[b];
	if(h[a]<h[b])swap(a,b);
	for(int i=lgn-1;i>=0;i--){
		if(par[i][a]!=-1&&h[par[i][a]]>=h[b]){
			a=par[i][a];
		}
	}
	if(a!=b){
		for(int i=lgn-1;i>=0;i--){
			if(par[i][a]!=par[i][b]){
				a=par[i][a];
				b=par[i][b];
			}
		}
		a=par[0][a];
		b=par[0][b];
	}
	ret-=2*h[a];
	return ret;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	pre();
	scanf("%d %d",&n,&m);
	for(int i=1,a,b;i<n;i++){
		scanf("%d %d",&a,&b);
		a--;
		b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	pre_dfs(0,0);
	red.push_back(mp(0,0));
	for(int i=0,a,b;i<m;i++){
		scanf("%d %d",&a,&b);
		b--;

		if(a==1){
			red.push_back(mp(b,0));
			if(red.size()==V_){
				multi_bfs();
				red.clear();
			}
		}
		else{
			ANS=dp[b];
			for(int j=0;j<red.size();j++){
				lca=LCA(red[j].first,b);
				ANS=min(ANS,lca);
			}
			printf("%d\n",ANS);
		}
	}
	if(1==1){
		n=14;
	}
}


#include<bits/stdc++.h>
using namespace std;
const int mxmx=1e5+1,lgn=17,V_=77,inf=1e9+10;

#define mp make_pair
#define X first
#define Y second

//MAIN
int n,m;
vector<int>adj[mxmx];
vector<pair<int,int> >red;
int dp[mxmx];
//LCA
int par[lgn][mxmx];
int h[mxmx];
//ANS
int ANS;
int lca;

inline void pre(){
	fill(dp,dp+mxmx,inf);
	for(int i=0;i<mxmx;i++){
		for(int j=0;j<lgn;j++){
			par[j][i]=-1;
		}
	}
}

inline void multi_bfs(){
	int ver,next,dist;
	for(int i=0;i<red.size();i++){
		ver=red[i].X;
		dist=red[i].Y;
		if(dp[ver]<=dist)continue;
		dp[ver]=dist;
		for(int j=0;j<adj[ver].size();j++){
			next=adj[ver][j];
			red.push_back(mp(next,dist+1));
		}
	}
}

inline void pre_dfs(int ver,int H){
	int next;
	h[ver]=H;
	for(int i=1;i<lgn;i++){
		if(par[i-1][ver]!=-1)par[i][ver]=par[i-1][par[i-1][ver]];
		else par[i][ver]=-1;
	}
	for(int i=0;i<adj[ver].size();i++){
		next=adj[ver][i];
		if(next!=par[0][ver]){
			par[0][next]=ver;
			pre_dfs(next,H+1);
		}
	}
}

inline int LCA(int a,int b){
	int ret;
	ret=h[a]+h[b];
	if(h[a]<h[b])swap(a,b);
	for(int i=lgn-1;i>=0;i--){
		if(par[i][a]!=-1&&h[par[i][a]]>=h[b]){
			a=par[i][a];
		}
	}
	if(a!=b){
		for(int i=lgn-1;i>=0;i--){
			if(par[i][a]!=par[i][b]){
				a=par[i][a];
				b=par[i][b];
			}
		}
		a=par[0][a];
		b=par[0][b];
	}
	ret-=2*h[a];
	return ret;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	pre();
	scanf("%d %d",&n,&m);
	for(int i=1,a,b;i<n;i++){
		scanf("%d %d",&a,&b);
		a--;
		b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	pre_dfs(0,0);
	red.push_back(mp(0,0));
	for(int i=0,a,b;i<m;i++){
		scanf("%d %d",&a,&b);
		b--;

		if(a==1){
			red.push_back(mp(b,0));
			if(red.size()==V_){
				multi_bfs();
				red.clear();
			}
		}
		else{
			ANS=dp[b];
			for(int j=0;j<red.size();j++){
				lca=LCA(red[j].first,b);
				ANS=min(ANS,lca);
			}
			printf("%d\n",ANS);
		}
	}
	if(1==1){
		n=35;
	}
}


#include<bits/stdc++.h>
using namespace std;
const int mxmx=1e5+10,lgn=20,V_=320,inf=1e9+10;

#define int long long
#define mp make_pair
#define X first
#define Y second

//MAIN
int n,m;
vector<int>adj[mxmx];
vector<pair<int,int> >red;
int dp[mxmx];
//LCA
int par[mxmx][lgn];
int h[mxmx];
//ANS
int ANS;
int lca;

void pre(){
	memset(dp,inf,mxmx);
	memset(par,-1,mxmx*lgn);
}

void multi_bfs(){
	int ver,next,dist;
	for(int i=0;i<red.size();i++){
		ver=red[i].X;
		dist=red[i].Y;
		if(dp[ver]<=dist)continue;
		dp[ver]=dist;
		for(int j=0;j<adj[ver].size();j++){
			next=adj[ver][j];
			red.push_back(mp(next,dist+1));
		}
	}
}

void pre_dfs(int ver,int H){
	int next;
	h[ver]=H;
	for(int i=1;i<lgn;i++){
		if(par[ver][i-1]!=-1)par[ver][i]=par[par[ver][i-1]][i-1];
		else par[ver][i]=-1;
	}
	for(int i=0;i<adj[ver].size();i++){
		next=adj[ver][i];
		if(next!=par[ver][0]){
			par[next][0]=ver;
			pre_dfs(next,H+1);
		}
	}
}

int LCA(int a,int b){
	int A,B;
	A=a;
	B=b;
	if(h[a]<h[b])swap(a,b);
	for(int i=lgn-1;i>=0;i--){
		if(h[par[a][i]]>=h[b]){
			a=par[a][i];
		}
	}
	if(a!=b){
		for(int i=lgn-1;i>=0;i--){
			if(par[a][i]!=par[b][i]){
				a=par[a][i];
				b=par[b][i];
			}
		}
		a=par[a][0];
		b=par[b][0];
	}
	return h[B]-h[a]+h[A]-h[a];
}

int32_t main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	pre();
	cin>>n>>m;
	for(int i=1,a,b;i<n;i++){
		cin>>a>>b;
		a--;
		b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	pre_dfs(0,0);
	red.push_back(mp(0,0));
	for(int i=0,a,b;i<m;i++){
		cin>>a>>b;
		b--;
		if(a==1){
			red.push_back(mp(b,0));
			if(red.size()==V_){
				multi_bfs();
				red.clear();
			}
		}
		else{
			ANS=dp[b];
			for(int j=0;j<red.size();j++){
				lca=LCA(red[j].first,b);
				ANS=min(ANS,lca);
			}
			cout<<ANS<<endl;
		}
	}
}


using System;

namespace ConsoleApplication1
{
    public class Program
    {
        public static void Main(string[] args)
        {
            const long maxn = 2 * 10 *10 *10*10*10;
            long n, k;
            double sum1 = 0;
            string sum2;
            long[] a = new long[maxn];
            long[] sum = new long[maxn];
            sum[0] = 0;
            string[] mas = Console.ReadLine().Split(' ');
            n = Convert.ToInt32(mas[0]);
            k = Convert.ToInt32(mas[1]);
            string[] mas1 = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
                a[i] = Convert.ToInt32(mas1[i]);
            for (int i = 0; i < k; i++)
                sum[0] += a[i];
            for (int i = 1; i < n - k + 1; i++)
                sum[i] = sum[i - 1] + a[i + k - 1] - a[i - 1];
            for (int i = 0; i < n - k + 1; i++)
                sum1 += sum[i];
            sum1 /= n - k + 1;
            sum2 =String.Format("{0:f10}", sum1);
            Console.WriteLine(sum2.Replace(',', '.'));
        }
    }
}


using System;
namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            const int maxn = 2 * 10 ^ 5;
            int n, k;
            float sum1 = 0;
            int[] a = new int[maxn];
            int[] sum = new int[maxn];
            sum[0] = 0;
            string[] mas = Console.ReadLine().Split(' ');
            n = Convert.ToInt32(mas[0]);
            k = Convert.ToInt32(mas[1]);
            string[] mas1 = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
                a[i] = Convert.ToInt32(mas1[i]);
            for (int i = 0; i < k; i++)
                sum[0] += a[i];
            for (int i = 1; i < n - k + 1; i++)
                sum[i] = sum[i - 1] + a[i + k - 1] - a[i - 1];
            for (int i = 0; i < n - k + 1; i++)
                sum1 += sum[i];
            sum1 /= n - k + 1;
            Console.WriteLine("{0:0.0000000000}",sum1);
        }
    }
}


using System;
using System.Threading;
using System.Globalization;
namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            CultureInfo.CurrentCulture = new CultureInfo("en-US");
            const int maxn = 2 * 10 ^ 5;
            int n, k;
            double sum1 = 0;
            string sum2;
            int[] a = new int[maxn];
            int[] sum = new int[maxn];
            sum[0] = 0;
            string[] mas = Console.ReadLine().Split(' ');
            n = Convert.ToInt32(mas[0]);
            k = Convert.ToInt32(mas[1]);
            string[] mas1 = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
                a[i] = Convert.ToInt32(mas1[i]);
            for (int i = 0; i < k; i++)
                sum[0] += a[i];
            for (int i = 1; i < n - k + 1; i++)
                sum[i] = sum[i - 1] + a[i + k - 1] - a[i - 1];
            for (int i = 0; i < n - k + 1; i++)
                sum1 += sum[i];
            sum1 /= n - k + 1;
            Console.WriteLine("{0:f10}", sum1);
        }
    }
}


using System;

namespace ConsoleApplication1
{
    public class Program
    {
        public static void Main(string[] args)
        {
            const int maxn = 2 * 10 *10 *10*10*10;
            int n, k;
            double sum1 = 0;
            string sum2;
            int[] a = new int[maxn];
            int[] sum = new int[maxn];
            sum[0] = 0;
            string[] mas = Console.ReadLine().Split(' ');
            n = Convert.ToInt32(mas[0]);
            k = Convert.ToInt32(mas[1]);
            string[] mas1 = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
                a[i] = Convert.ToInt32(mas1[i]);
            for (int i = 0; i < k; i++)
                sum[0] += a[i];
            for (int i = 1; i < n - k + 1; i++)
                sum[i] = sum[i - 1] + a[i + k - 1] - a[i - 1];
            for (int i = 0; i < n - k + 1; i++)
                sum1 += sum[i];
            sum1 /= n - k + 1;
            sum2 =String.Format("{0:f10}", sum1);
            Console.WriteLine(sum2.Replace(',', '.'));
        }
    }
}


using System;
namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            const int maxn = 2 * 10 ^ 5;
            int n, k;
            float sum1 = 0f;
            int[] a = new int[maxn];
            int[] sum = new int[maxn];
            n = Convert.ToInt32(Console.Read());
            k = Convert.ToInt32(Console.Read());
            for (int i = 0; i < n; i++)
                a[i] = Convert.ToInt32(Console.Read());
            for (int i = 0; i < k; i++)
                sum[0] += a[i];
            for (int i = 1; i < n - k + 1; i++)
                sum[i] = sum[i - 1] + a[i + k - 1] - a[i - 1];
            for (int i = 0; i < n - k + 1; i++)
                sum1 += sum[i];
            sum1 /= n - k + 1;
            Console.WriteLine("{0:f12}", sum1);
        }
    }
}


using System;
using System.Globalization;

namespace ConsoleApplication1
{
    public class Program
    {
        public static void Main(string[] args)
        {
            CultureInfo.CurrentCulture = new CultureInfo("en-US");
            const int maxn = 2 * 10 ^ 5;
            int n, k;
            double sum1 = 0;
            int[] a = new int[maxn];
            int[] sum = new int[maxn];
            sum[0] = 0;
            string[] mas = Console.ReadLine().Split(' ');
            n = Convert.ToInt32(mas[0]);
            k = Convert.ToInt32(mas[1]);
            string[] mas1 = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
                a[i] = Convert.ToInt32(mas1[i]);
            for (int i = 0; i < k; i++)
                sum[0] += a[i];
            for (int i = 1; i < n - k + 1; i++)
                sum[i] = sum[i - 1] + a[i + k - 1] - a[i - 1];
            for (int i = 0; i < n - k + 1; i++)
                sum1 += sum[i];
            sum1 /= n - k + 1;
            Console.WriteLine("{0:f10}", sum1);
        }
    }
}


using System;

namespace ConsoleApplication1
{
    public class Program
    {
        public static void Main(string[] args)
        {
            const int maxn = 2 * 10 ^ 5;
            int n, k;
            double sum1 = 0;
            string sum2;
            int[] a = new int[maxn];
            int[] sum = new int[maxn];
            sum[0] = 0;
            string[] mas = Console.ReadLine().Split(' ');
            n = Convert.ToInt32(mas[0]);
            k = Convert.ToInt32(mas[1]);
            string[] mas1 = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
                a[i] = Convert.ToInt32(mas1[i]);
            for (int i = 0; i < k; i++)
                sum[0] += a[i];
            for (int i = 1; i < n - k + 1; i++)
                sum[i] = sum[i - 1] + a[i + k - 1] - a[i - 1];
            for (int i = 0; i < n - k + 1; i++)
                sum1 += sum[i];
            sum1 /= n - k + 1;
            sum2 =String.Format("{0:f10}", sum1);
            Console.WriteLine(sum2.Replace(',', '.'));
        }
    }
}


using System;
namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            const int maxn = 2 * 10 ^ 5;
            int n, k;
            double sum1 = 0;
            int[] a = new int[maxn];
            int[] sum = new int[maxn];
            sum[0] = 0;
            string[] mas = Console.ReadLine().Split(' ');
            n = Convert.ToInt32(mas[0]);
            k = Convert.ToInt32(mas[1]);
            string[] mas1 = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
                a[i] = Convert.ToInt32(mas1[i]);
            for (int i = 0; i < k; i++)
                sum[0] += a[i];
            for (int i = 1; i < n - k + 1; i++)
                sum[i] = sum[i - 1] + a[i + k - 1] - a[i - 1];
            for (int i = 0; i < n - k + 1; i++)
                sum1 += sum[i];
            sum1 /= n - k + 1;
            Console.WriteLine("{0:0.0000000000}",sum1);
        }
    }
}


using System;
using System.Globalization;
using System.IO;
using System.Text;

namespace Average_Sleep_Time
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            int n = Next();
            int k = Next();

            var nn = new int[n];
            for (int i = 0; i < n; i++)
            {
                nn[i] = Next();
            }

            long sum = 0;
            int count = n - k + 1;
            for (long i = 0; i < k; i++)
            {
                sum += (i + 1)*nn[i];
                if (n - i - 1 == i)
                    break;
                sum += (i + 1)*nn[n - i - 1];
            }

            for (int i = n - k - 1; i >= k; i--)
            {
                sum += k*nn[i];
            }

            writer.WriteLine("{0}", (1.0*sum/count).ToString("#0.0000000", CultureInfo.InvariantCulture));
            writer.Flush();
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;
using System.Globalization;
using System.IO;
using System.Text;

namespace Average_Sleep_Time
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            int n = Next();
            int k = Next();

            var nn = new int[n];
            for (int i = 0; i < n; i++)
            {
                nn[i] = Next();
            }

            long sum = 0;
            int count = n - k + 1;
            for (long i = 0; i < k; i++)
            {
                if (n - i - 1 < i)
                    break;
                sum += (i + 1)*nn[i];
                if (n - i - 1 == i)
                    break;
                sum += (i + 1)*nn[n - i - 1];
            }

            for (int i = n - k - 1; i >= k; i--)
            {
                sum += k*nn[i];
            }

            writer.WriteLine("{0}", (1.0*sum/count).ToString("#0.0000000", CultureInfo.InvariantCulture));
            writer.Flush();
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;
using System.Globalization;
using System.IO;
using System.Text;

namespace Average_Sleep_Time
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            int n = Next();
            int k = Next();

            var nn = new int[n];
            for (int i = 0; i < n; i++)
            {
                nn[i] = Next();
            }

            long sum = 0;
            int count = n - k + 1;
            for (long i = 0; i < k; i++)
            {
                if (n - i - 1 < i)
                    break;
                sum += Math.Min(i + 1, count)*nn[i];
                if (n - i - 1 == i)
                    break;
                sum += Math.Min(i + 1, count)*nn[n - i - 1];
            }

            for (int i = n - k - 1; i >= k; i--)
            {
                sum += (long)k*nn[i];
            }

            writer.WriteLine("{0}", (1.0*sum/count).ToString("#0.0000000", CultureInfo.InvariantCulture));
            writer.Flush();
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;

namespace _808B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]), k = int.Parse(input[1]);
            double[] a = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
            double sum = 0;
            for (int i = 0; i < k; i++)
                sum += a[i];
            double result = sum / (n - k + 1);
            for (int i = k; i < n; i++)
            {
                sum += a[i];
                sum -= a[i - k];
                result += sum / (n - k + 1);
            }
            Console.WriteLine(result.ToString(System.Globalization.CultureInfo.InvariantCulture));
        }
    }
}


using System;
using System.IO;
using System.Linq;

namespace cptest
{
    class Program
    {
        static void Main(string[] args)
        {
            #if !ONLINE_JUDGE
                string filename = "input.txt";
                Console.SetIn(new StreamReader(new FileStream(filename, FileMode.Open)));
            #endif
            Solve();
        }
        static void Solve() {
            string[] input = Console.ReadLine().Split();
            long n = long.Parse(input[0]), k = long.Parse(input[1]);
            var arr = Console.ReadLine().Split().Select(long.Parse).ToList();
            long sum = 0;
            for(int i = 0; i < arr.Count(); i++) {
                long times = Math.Min(k, Math.Min(i + 1, n - i));
                sum += times * arr[i];
            }
            double res = sum/(double)(n - k + 1);
            Console.WriteLine(res.ToString("0.0000000"));
        }
    }
}


using System;
using System.IO;
using System.Linq;
using System.Globalization;

namespace cptest
{
    class Program
    {
        static void Main(string[] args)
        {
            #if !ONLINE_JUDGE
                string filename = "input.txt";
                Console.SetIn(new StreamReader(new FileStream(filename, FileMode.Open)));
            #endif
            Solve();
        }
        static void Solve() {
            string[] input = Console.ReadLine().Split();
            long n = long.Parse(input[0]), k = long.Parse(input[1]);
            var arr = Console.ReadLine().Split().Select(long.Parse).ToList();
            long sum = 0;
            for(int i = 0; i < arr.Count(); i++) {
                long times = Math.Min(k, Math.Min(i + 1, n - i));
                sum += times * arr[i];
            }
            double res = sum/(double)(n - k + 1);
            Console.WriteLine(res.ToString(CultureInfo.InvariantCulture));
        }
    }
}


using System;
using System.IO;
using System.Linq;

namespace cptest
{
    class Program
    {
        static void Main(string[] args)
        {
            #if !ONLINE_JUDGE
                string filename = "input.txt";
                Console.SetIn(new StreamReader(new FileStream(filename, FileMode.Open)));
            #endif
            Solve();
        }
        static void Solve() {
            string[] input = Console.ReadLine().Split();
            long n = long.Parse(input[0]), k = long.Parse(input[1]);
            var arr = Console.ReadLine().Split().Select(long.Parse).ToList();
            long sum = 0;
            for(int i = 0; i < arr.Count(); i++) {
                long times = Math.Min(k, Math.Min(i + 1, n - i));
                sum += times * arr[i];
            }
            double res = sum/(double)(n - k + 1);
            Console.WriteLine(res);
        }
    }
}


using System;
using System.IO;
using System.Linq;
using System.Globalization;

namespace cptest
{
    class Program
    {
        static void Main(string[] args)
        {
            #if !ONLINE_JUDGE
                string filename = "input.txt";
                Console.SetIn(new StreamReader(new FileStream(filename, FileMode.Open)));
            #endif
            Solve();
        }
        static void Solve() {
            string[] input = Console.ReadLine().Split();
            long n = long.Parse(input[0]), k = long.Parse(input[1]);
            var arr = Console.ReadLine().Split().Select(long.Parse).ToList();
            long sum = 0;
            for(int i = 0; i < arr.Count(); i++) {
                long times = Math.Min(Math.Min(n - k + 1, k), Math.Min(i + 1, n - i));
                sum += times * arr[i];
            }
            double res = sum/(double)(n - k + 1);
            Console.WriteLine(res.ToString(CultureInfo.InvariantCulture));
        }
    }
}


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

namespace CF
{
	internal class Program
	{
		private static void Main(string[] args)
		{
			var sr = new InputReader(Console.In);
			//var sr = new InputReader(new StreamReader("input.txt"));
			var task = new Task();
			using (var sw = Console.Out)
			{
				//using (var sw = new StreamWriter("output.txt")) {
				task.Solve(sr, sw);
				//Console.ReadKey();
			}
		}
	}

	internal class Task
	{
		public void Solve(InputReader sr, TextWriter sw)
		{
			var input = sr.ReadArray(Int32.Parse);
			var n = input[0];
			var k = input[1];
			var a = sr.ReadArray(Int32.Parse);
			var weeks = (n - k + 1);
			var totalSum = 0L;
			var sum = 0L;
			for (var i = 0; i < a.Length; i++) {
				if (i > 0 && i >= k) {
					totalSum += sum;
					sum -= a[i - k];
				}
				sum += a[i];
			}
			totalSum += sum;
			var r = (double) totalSum / weeks;

			sw.WriteLine(r.ToString("F8", CultureInfo.InvariantCulture));
		}
	}
}

internal class InputReader : IDisposable
{
	private bool isDispose;
	private readonly TextReader sr;

	public InputReader(TextReader stream)
	{
		sr = stream;
	}

	public void Dispose()
	{
		Dispose(true);
		GC.SuppressFinalize(this);
	}

	public string NextString()
	{
		var result = sr.ReadLine();
		return result;
	}

	public int NextInt32()
	{
		return Int32.Parse(NextString());
	}

	public long NextInt64()
	{
		return Int64.Parse(NextString());
	}

	public string[] NextSplitStrings()
	{
		return NextString()
										.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
	}

	public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
	{
		return NextSplitStrings()
										.Select(s => func(s, CultureInfo.InvariantCulture))
										.ToArray();
	}

	public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
	{
		return
										str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
																		.Select(s => func(s, CultureInfo.InvariantCulture))
																		.ToArray();
	}

	protected void Dispose(bool dispose)
	{
		if (!isDispose)
		{
			if (dispose)
				sr.Close();
			isDispose = true;
		}
	}

	~InputReader()
	{
		Dispose(false);
	}
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace ConsoleApplication1A
{
  class ProgramAAA
  {

    static void Main()
    {

      //int n = Convert.ToInt32(Console.ReadLine());

        string[] tk = Console.ReadLine().Split(' ');
        long n = Convert.ToInt32(tk[0]);
        long k = Convert.ToInt32(tk[1]);

        tk = Console.ReadLine().Split(' ');
        long[] M = new long[n];
        for (var i = 0; i < n; i++)
          M[i] = Convert.ToInt64(tk[i]);

        long s = 0;
        long curs = 0;

        for (var i = 0; i < k; i++)
          curs = curs + M[i];

        long d = 0;
        for (var i = k; i < n; i++)
        {
          s = s + curs;
          curs = curs - M[i - k] + M[i];
          d++;
        }
        d++;
        s = s + curs;

        double r = (double)s / (double)d;

        NumberFormatInfo nfi = new NumberFormatInfo();
        nfi.NumberDecimalSeparator = ".";

        Console.WriteLine(r.ToString(nfi));

    }

  }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeForces.Problems.B
{
    class _808
    {
        public static void Main()
        {
            var input = GetInts(2).GetEnumerator();
            var n = input.MoveNext() ? input.Current : 0;
            var k = input.MoveNext() ? input.Current : 0;

            var a = GetInts(n).ToArray();
            var avg = 0d;
            var queue = new Queue(k);

            for (int i = 0; i < k - 1; i++)
            {
                queue.Enqueue(a[i]);
            }

            for (int i = k - 1; i < n; i++, avg += ((double)queue.GetSum() / (double)(n - k + 1)))
            {
                queue.Enqueue(a[i]);
            }

            Console.Write(avg.ToString().Replace(',', '.'));
        }

        private static IEnumerable<int> GetInts(int count)
        {
            Stack<int> stack = new Stack<int>();

            for (int i = 0; i < count; i++)
            {
                char ch = (char)Console.Read();
                while (!char.IsDigit(ch))
                {
                    ch = (char)Console.Read();
                }

                while (char.IsDigit(ch))
                {
                    stack.Push((int)char.GetNumericValue(ch));
                    ch = (char)Console.Read();
                }

                int current = 0;
                for (int rank = 1; stack.Count > 0; rank *= 10)
                {
                    current += rank * stack.Pop();
                }

                yield return current;
            }
        }

        private class Queue
        {
            int[] _values;
            int _pointer;
            long _sum;

            public Queue(int size)
            {
                _values = new int[size];
                _pointer = -1;
                _sum = 0;
            }

            public void Enqueue(int value)
            {
                _pointer = (_pointer + 1) % _values.Length;
                _sum = (_sum - _values[_pointer] + value);
                _values[_pointer] = value;
            }

            public long GetSum()
            {
                return _sum;
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeForces.Problems.B
{
    class _808
    {
        public static void Main()
        {
            var input = GetInts(2).GetEnumerator();
            var n = input.MoveNext() ? input.Current : 0;
            var k = input.MoveNext() ? input.Current : 0;

            var a = GetInts(n).ToArray();
            var sum = 0L;

            for (int i = 0; i <= n - k; i++)
            {
                for (int j = i; j < i + k; j++)
                {
                    sum += a[j];
                }
            }

            var result = (double)sum / (double)(n - k + 1);
            Console.Write(result.ToString().Replace('.', ','));
        }

        private static IEnumerable<int> GetInts(int count)
        {
            Stack<int> stack = new Stack<int>();

            for (int i = 0; i < count; i++)
            {
                char ch = (char)Console.Read();
                while (!char.IsDigit(ch))
                {
                    ch = (char)Console.Read();
                }

                while (char.IsDigit(ch))
                {
                    stack.Push((int)char.GetNumericValue(ch));
                    ch = (char)Console.Read();
                }

                int current = 0;
                for (int rank = 1; stack.Count > 0; rank *= 10)
                {
                    current += rank * stack.Pop();
                }

                yield return current;
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeForces.Problems.B
{
    class _808
    {
        public static void Main()
        {
            var input = GetInts(2).GetEnumerator();
            var n = input.MoveNext() ? input.Current : 0;
            var k = input.MoveNext() ? input.Current : 0;

            var a = GetInts(n).ToArray();
            var avg = 0d;
            var queue = new Queue(k);

            for (int i = 0; i < k - 1; i++)
            {
                queue.Enqueue(a[i]);
            }

            for (int i = k - 1; i < n; i++, avg += ((double)queue.GetSum() / (double)(n - k + 1)))
            {
                queue.Enqueue(a[i]);
            }

            Console.Write(avg.ToString().Replace(',', '.'));
        }

        private static IEnumerable<int> GetInts(int count)
        {
            Stack<int> stack = new Stack<int>();

            for (int i = 0; i < count; i++)
            {
                char ch = (char)Console.Read();
                while (!char.IsDigit(ch))
                {
                    ch = (char)Console.Read();
                }

                while (char.IsDigit(ch))
                {
                    stack.Push((int)char.GetNumericValue(ch));
                    ch = (char)Console.Read();
                }

                int current = 0;
                for (int rank = 1; stack.Count > 0; rank *= 10)
                {
                    current += rank * stack.Pop();
                }

                yield return current;
            }
        }

        private class Queue
        {
            int[] _values;
            int _pointer;
            int _sum;

            public Queue(int size)
            {
                _values = new int[size];
                _pointer = -1;
                _sum = 0;
            }

            public void Enqueue(int value)
            {
                _pointer = (_pointer + 1) % _values.Length;
                _sum = (_sum - _values[_pointer] + value);
                _values[_pointer] = value;
            }

            public int GetSum()
            {
                return _sum;
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeForces.Problems.B
{
    class _808
    {
        public static void Main()
        {
            var input = GetInts(2).GetEnumerator();
            var n = input.MoveNext() ? input.Current : 0;
            var k = input.MoveNext() ? input.Current : 0;

            var a = GetInts(n).ToArray();
            var sum = 0L;

            for (int i = 0; i <= n - k; i++)
            {
                for (int j = i; j < i + k; j++)
                {
                    sum += a[j];
                }
            }

            Console.Write((double)sum / (double)(n - k + 1));
        }

        private static IEnumerable<int> GetInts(int count)
        {
            Stack<int> stack = new Stack<int>();

            for (int i = 0; i < count; i++)
            {
                char ch = (char)Console.Read();
                while (!char.IsDigit(ch))
                {
                    ch = (char)Console.Read();
                }

                while (char.IsDigit(ch))
                {
                    stack.Push((int)char.GetNumericValue(ch));
                    ch = (char)Console.Read();
                }

                int current = 0;
                for (int rank = 1; stack.Count > 0; rank *= 10)
                {
                    current += rank * stack.Pop();
                }

                yield return current;
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeForces.Problems.B
{
    class _808
    {
        public static void Main()
        {
            var input = GetInts(2).GetEnumerator();
            var n = input.MoveNext() ? input.Current : 0;
            var k = input.MoveNext() ? input.Current : 0;

            var a = GetInts(n).ToArray();
            var sum = 0L;
            var queue = new Queue(k);

            for (int i = 0; i < k - 1; i++)
            {
                queue.Enqueue(a[i]);
            }

            for (int i = k - 1; i < n; i++, sum += queue.GetSum())
            {
                queue.Enqueue(a[i]);
            }

            var result = (double)sum / (double)(n - k + 1);
            Console.Write(result.ToString().Replace(',', '.'));
        }

        private static IEnumerable<int> GetInts(int count)
        {
            Stack<int> stack = new Stack<int>();

            for (int i = 0; i < count; i++)
            {
                char ch = (char)Console.Read();
                while (!char.IsDigit(ch))
                {
                    ch = (char)Console.Read();
                }

                while (char.IsDigit(ch))
                {
                    stack.Push((int)char.GetNumericValue(ch));
                    ch = (char)Console.Read();
                }

                int current = 0;
                for (int rank = 1; stack.Count > 0; rank *= 10)
                {
                    current += rank * stack.Pop();
                }

                yield return current;
            }
        }

        private class Queue
        {
            int[] _values;
            int _pointer;
            int _sum;

            public Queue(int size)
            {
                _values = new int[size];
                _pointer = -1;
                _sum = 0;
            }

            public void Enqueue(int value)
            {
                _pointer = (_pointer + 1) % _values.Length;
                _sum = (_sum - _values[_pointer] + value);
                _values[_pointer] = value;
            }

            public int GetSum()
            {
                return _sum;
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeForces.Problems.B
{
    class _808
    {
        public static void Main()
        {
            var input = GetInts(2).GetEnumerator();
            var n = input.MoveNext() ? input.Current : 0;
            var k = input.MoveNext() ? input.Current : 0;

            var a = GetInts(n).ToArray();
            var sum = 0L;

            for (int i = 0; i <= n - k; i++)
            {
                for (int j = i; j < i + k; j++)
                {
                    sum += a[j];
                }
            }

            var result = (double)sum / (double)(n - k + 1);
            Console.Write(result.ToString().Replace(',', '.'));
        }

        private static IEnumerable<int> GetInts(int count)
        {
            Stack<int> stack = new Stack<int>();

            for (int i = 0; i < count; i++)
            {
                char ch = (char)Console.Read();
                while (!char.IsDigit(ch))
                {
                    ch = (char)Console.Read();
                }

                while (char.IsDigit(ch))
                {
                    stack.Push((int)char.GetNumericValue(ch));
                    ch = (char)Console.Read();
                }

                int current = 0;
                for (int rank = 1; stack.Count > 0; rank *= 10)
                {
                    current += rank * stack.Pop();
                }

                yield return current;
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Text.RegularExpressions;
using System.Threading;

namespace CodeForces
{
    class Program
    {
        public static string Rw() => Console.ReadLine();
        public static int GetInt() => Int32.Parse(Console.ReadLine());
        public static int[] GetArr() => Array.ConvertAll(Console.ReadLine().Split(' '), Int32.Parse);

        public static void Main(string[] args)
        {
            int[] arr = GetArr();
            int n = arr[0];
            int k = arr[1];
            arr = GetArr();

            double ans = 0;
            double sum = 0;
            for (int i = 0; i < k; i++)
                sum += arr[i];

            ans += sum/(n-k+1);

            for (int i = k; i < n; i++)
            {
                sum -= arr[i - k];
                sum += arr[i];
                ans += sum/(n-k+1);
            }

            Console.WriteLine(ans);
        }
    }

}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Text.RegularExpressions;
using System.Threading;

namespace CodeForces
{
    class Program
    {
        public static string Rw() => Console.ReadLine();
        public static int GetInt() => Int32.Parse(Console.ReadLine());
        public static int[] GetArr() => Array.ConvertAll(Console.ReadLine().Split(' '), Int32.Parse);

        public static void Main(string[] args)
        {
            int[] arr = GetArr();
            int n = arr[0];
            int k = arr[1];
            arr = GetArr();

            double ans = 0;
            double sum = 0;
            for (int i = 0; i < k; i++)
                sum += arr[i];

            ans += sum/(n-k+1);

            for (int i = k; i < n; i++)
            {
                sum -= arr[i - k];
                sum += arr[i];
                ans += sum/(n-k+1);
            }

            Console.WriteLine("{0}", ans.ToString("F8", CultureInfo.CreateSpecificCulture("en-US")));
        }
    }

}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

class Program
{
    private static void SolveB()
    {

    }

    private static void SolveA()
    {
        int n = RI();
        int k = RI();
        var m = RIA(n);

        long[] sum = new long[n];
        sum[0] = m[0];
        for (int i = 1; i < n; i++) sum[i] = sum[i - 1] + m[i];

        long totalSum = 0;
        for (int i = 0; i < n - k + 1; i++)
        {
            var s = sum[i + k - 1];
            if (i > 0)
                s -= sum[i - 1];

            totalSum += s;
        }

        double ans = (totalSum / (1.0 * (n - k + 1)));
        Console.WriteLine(DoubleToString(ans));
    }

    static void Main(string[] args)
    {
        SolveA();
    }

    private const int Mod = 1000000000 + 7;

    #region Data Read

    private static long GCD(long a, long b)
    {
        if (a % b == 0) return b;
        return GCD(b, a % b);
    }

    private static List<int>[] ReadGraph(int n, int m)
    {
        List<int>[] g = new List<int>[n];
        for (int i = 0; i < g.Length; i++) g[i] = new List<int>();
        for (int i = 0; i < m; i++)
        {
            int a = RI() - 1;
            int b = RI() - 1;

            g[a].Add(b);
            g[b].Add(a);
        }

        return g;
    }

    private static int[,] ReadGraphAsMatrix(int n, int m)
    {
        int[,] matrix = new int[n + 1, n + 1];
        for (int i = 0; i < m; i++)
        {
            int a = RI();
            int b = RI();
            matrix[a, b] = matrix[b, a] = 1;
        }

        return matrix;
    }

    private static void Sort(ref int a, ref int b)
    {
        if (a > b) Swap(ref a, ref b);
    }

    private static void Swap(ref int a, ref int b)
    {
        int tmp = a;
        a = b;
        b = tmp;
    }

    private const int BufferSize = 1 << 16;
    private static StreamReader consoleReader;
    private static MemoryStream testData;

    private static int RI()
    {
        int ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static ulong RUL()
    {
        ulong ans = 0;
        int chr;
        do
        {
            chr = consoleReader.Read();
            if (chr == -1)
                return 0;
        } while (chr < '0' || chr > '9');

        ans = (uint)(chr - '0');
        while (true)
        {
            chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans;
            ans = ans * 10 + (uint)(chr - '0');
        }
    }

    private static long RL()
    {
        long ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static int[] RIA(int n)
    {
        int[] ans = new int[n];
        for (int i = 0; i < n; i++)
            ans[i] = RI();
        return ans;
    }

    private static long[] RLA(int n)
    {
        long[] ans = new long[n];
        for (int i = 0; i < n; i++)
            ans[i] = RL();
        return ans;
    }

    private static char[] ReadWord()
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));

        List<char> s = new List<char>();
        do
        {
            s.Add((char)ans);
            ans = consoleReader.Read();
        } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));

        return s.ToArray();
    }

    private static char[] ReadString(int n)
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));

        char[] s = new char[n];
        int pos = 0;
        do
        {
            s[pos++] = (char)ans;
            if (pos == n) break;
            ans = consoleReader.Read();
        } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));

        return s;
    }

    private static char[] ReadStringLine()
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (ans == 10 || ans == 13);

        List<char> s = new List<char>();

        do
        {
            s.Add((char)ans);
            ans = consoleReader.Read();
        } while (ans != 10 && ans != 13 && ans != -1);

        return s.ToArray();
    }

    private static char ReadLetter()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'))
                return (char)ans;
        }
    }
    private static char ReadNonLetter()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')))
                return (char)ans;
        }
    }

    private static char ReadAnyOf(IEnumerable<char> allowed)
    {
        while (true)
        {
            char ans = (char)consoleReader.Read();
            if (allowed.Contains(ans))
                return ans;
        }
    }

    private static char ReadDigit()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (ans >= '0' && ans <= '9')
                return (char)ans;
        }
    }

    private static int ReadDigitInt()
    {
        return ReadDigit() - (int)'0';
    }

    private static char ReadAnyChar()
    {
        return (char)consoleReader.Read();
    }

    private static string DoubleToString(double x)
    {
        return x.ToString(CultureInfo.InvariantCulture);
    }

    private static double DoubleFromString(string x)
    {
        return double.Parse(x, CultureInfo.InvariantCulture);
    }

    static Program()
    {
        //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);
    }

    private static void PushTestData(StringBuilder sb)
    {
        PushTestData(sb.ToString());
    }
    private static void PushTestData(string data)
    {
#if TOLYAN_TEST
        if (testData == null)
        {
            testData = new MemoryStream();
            consoleReader = new StreamReader(testData);
        }

        var pos = testData.Position;
        var bytes = Encoding.UTF8.GetBytes(data);
        testData.Write(bytes, 0, bytes.Length);
        testData.Flush();
        testData.Position = pos;
#endif
    }
    #endregion
}


fun main() {
    val (n, k) = readLine()!!.split(' ').map(String::toInt)
    val nums = readLine()!!.split(' ').map(String::toInt)
    var sum = 0.0
    var prev = 0.0
    var i = 0
    while (i < k) sum += nums[i++]
    prev = sum
    while (i < n) {
        var temp = prev
        temp -= nums[i - k]
        temp += nums[i]
        prev = temp
        sum += temp
        i++
    }
    println("%.6f".format(sum / (n - k + 1)))
}


fun main() {
    val (n, k) = readLine()!!.split(' ').map(String::toInt)
    val nums = readLine()!!.split(' ').map(String::toInt)
    var sum = 0.0f
    var prev = 0.0f
    var i = 0
    while (i < k) sum += nums[i++]
    prev = sum
    while (i < n) {
        var temp = prev
        temp -= nums[i - k]
        temp += nums[i]
        prev = temp
        sum += temp
        i++
    }
    println("%.6f".format(sum / (n - k + 1)))
}


import java.util.*

fun main(vararg args: String) {
    with(Scanner(System.`in`)) {
        val n = nextInt()
        val k = nextInt()
        val a = IntArray(n) { nextInt() }
        println(a.foldIndexed(0) { i, s, v -> s + listOf(k, i + 1, n - i).min()!! * v } / (n - k + 1).toDouble())
    }
}


import java.util.*

fun main(vararg args: String) {
    with(Scanner(System.`in`)) {
        val n = nextInt()
        val k = nextInt()
        val a = IntArray(n) { nextInt() }
        println(a.foldIndexed(0.0) { i, s, v ->
            s + k.coerceAtMost(n - k + 1).coerceAtMost(i + 1).coerceAtMost(n - i) * v.toDouble()
        } / (n - k + 1))
    }
}


import java.util.*

fun main(vararg args: String) {
    with(Scanner(System.`in`)) {
        val n = nextInt()
        val k = nextInt()
        val a = IntArray(n) { nextInt() }
        println(a.foldIndexed(0.0) { i, s, v -> s + k.coerceAtMost(i + 1).coerceAtMost(n - i) * v.toDouble() } / (n - k + 1))
    }
}


import java.util.*

fun main(vararg args: String) {
    with(Scanner(System.`in`)) {
        val n = nextInt()
        val k = nextInt()
        val a = IntArray(n) { nextInt() }
        println(a.foldIndexed(0.0) { i, s, v ->
            s + k.coerceAtMost(n - k + 1).coerceAtMost(i + 1).coerceAtMost(n - i) * v.toDouble()
        } / n - k + 1)
    }
}


import java.util.*

fun main(vararg args: String) {
    with(Scanner(System.`in`)) {
        val n = nextInt()
        val k = nextInt()
        val a = IntArray(n) { nextInt() }
        val d = (n - k + 1).toDouble()
        println(a.foldIndexed(0.0) { i, s, v -> s + k.coerceAtMost(i + 1).coerceAtMost(n - i) / d * v })
    }
}


fun main(args: Array<String>) {
    val reg = Regex(" ")
    var s = readLine()!!.split(reg)
    val n = s[0].toInt()
    val k = s[1].toInt()
    s = readLine()!!.split(reg)
    var ans: Double = 0.0
    var cur: Long = 0
    for (i in 0..k - 1)
        cur += s[i].toLong()
    ans += cur
    for (i in k..n - 1){
        cur -= s[i - k].toLong()
        cur += s[i].toLong()
        ans += cur
    }
    println(ans / (n - k + 1))
}


fun main(args: Array<String>){
    val reg = Regex(" ")
    var s = readLine()!!.split(reg)
    val n = s[0].toInt()
    val k = s[1].toInt()
    s = readLine()!!.split(reg)
    var cur: Long = (0..n - 1).map { 2 * s[it].toLong() }.sum()
    cur -= s[0].toLong()
    if (n > 1)
        cur -= s[n - 1].toLong()
    println(cur.toDouble() / (n - k + 1).toDouble())
}


#include<stdio.h>
int main()
{
    long long int n,m;
    while(scanf("%lld %lld",&n,&m)==2)
    {
        long long int i,array[200000]={0},temp,div=(n-m+1);
        double sleep,total=0.0000000000;
        for(i=0;i<n;i++)
        {
            scanf("%lld",&temp);
            if(i)
            {
                array[i]+=array[i-1]+temp;
            }
            else array[i]=temp;
        }
        for(i=m-1;i<n;i++)
        {
            if(i-m>=0)total+=array[i]-array[i-m];
            else total+=array[i];
        }
        printf("%.10lf\n",total/div);
    }
    return 0;
}


#include <stdio.h>

int main()
{
    double ans, a[200005], dp[200005];
    int i, j, n, k;
    scanf("%d%d", &n, &k);
    ans = 0;
    for(i = 0 ; i < 200005 ; i++)
        dp[i] = 0;
    for(i = 0 ; i < n ; i++)
    {
        scanf("%lf", a + i);
        if(i)
            dp[i] = dp[i - 1] + a[i];
        else dp[i] = a[i];
        if(i >= k)
            ans += dp[i] - dp[i - k];
        else if(i == k - 1)
            ans += dp[i];
    }
    printf("%.7lf\n", ans /(double) (n - k + 1));

    return 0;
}


#include <stdio.h>

int main()
{
    double ans, k, n, a[200005];
    int i, j;
    scanf("%lf%lf", &n, &k);
    ans = 0;
    for(i = 0 ; i < n ; i++)
    {
        scanf("%lf", a + i);
        if(i && i != n - 1)
            ans += a[i] * 2;
        else ans += a[i];
    }
    printf("%lf\n", ans / (n - k + 1));

    return 0;
}


#include <stdio.h>

int main()
{
    double ans, a[200005];
    int i, j, n, k;
    scanf("%d%d", &n, &k);
    ans = 0;
    for(i = 0 ; i < n ; i++)
    {
        scanf("%lf", a + i);
        if(i + 1 >= k)
        {
            for(j = i + 1 - k ; j <= i ; j++)
            {
                ans += a[j];
            }
        }
    }
    printf("%.7lf\n", ans /(double) (n - k + 1));

    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main(){
	unsigned int i, j, n, k, week, op;
	double total=0;
	unsigned int *a;

	scanf("%d %d", &n, &k);
	week=n-k+1;
	op=n-week+1;
	a=(int*)malloc(sizeof(int)*n);

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

	for(i=0; i<op; i++){
		j=i;
		while(j<(i+week)) {
			total = total+a[j];
			j++;
		}
	}

	total = total/week;
	printf("%6f", total);
}


#include <stdio.h>
#include <stdlib.h>

int main(){
	int i, j, n, k, week, op;
	double total=0;
	unsigned int *a;

	scanf("%d %d", &n, &k);
	week=n-k+1;
	op=i+week;
	a=(int*)malloc(sizeof(int)*n);

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

	for(i=0; i<(n-op); i++){
		for(j=i; j<op; j++) total = total+a[j];
	}

	total = total/week;
	printf("%6f", total);
}


#include <stdio.h>
#include <stdlib.h>

int main(){
	unsigned int i, j, n, k, week, op;
	double total=0;
	unsigned int *a;

	scanf("%d %d", &n, &k);
	week=n-k+1;
	op=n-week+1;
	a=(int*)malloc(sizeof(int)*n);

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

	for(i=(op-1); i>0; i--){
		for(j=i; j>(i-week); j--) total = total+a[j];
	}

	total = total/week;
	printf("%6f", total);
}


#include <stdio.h>
#include <stdlib.h>

int main(){
	int i, n, k;
	double total=0;
	int *a;

	scanf("%d %d", &n, &k);
	a=(int*)malloc(sizeof(int)*n);

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

	for(i=0; i<(n-1); i++){
		total = total+(a[i]+a[i+1]);
	}

	k=n-k+1;
	total = total/k;
	printf("%6f", total);
}


#include <stdio.h>
#include <stdlib.h>

int main(){
	int i, j, n, k, week;
	double total=0;
	unsigned int *a;

	scanf("%d %d", &n, &k);
	week=n-k+1;
	a=(int*)malloc(sizeof(int)*n);

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

	for(i=0; i<(n-week+1); i++){
		for(j=i; j<(i+week); j++) total = total+a[j];
	}

	total = total/week;
	printf("%6f", total);
}


#include <stdio.h>
#include <stdlib.h>

int main(){
	int i, j, n, k, week, op;
	double total=0, num;
	unsigned int *a;

	scanf("%d %d", &n, &k);
	week=n-k+1;
	op=n-week+1;
	a=(int*)malloc(sizeof(int)*n);

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

	for(i=0; i<week; i++) total=total+a[i];
	num=total;

	for(i=1; i<op; i++){
		num=num-a[i-1]+a[i+week-1];
		total=total+num;
	}

	total = total/week;
	printf("%6f", total);
}


#include <stdio.h>
#include <stdlib.h>

int main(){
	int i, n, k;
	double total=0;
	int *a;

	scanf("%d %d", &n, &k);
	a=(int*)malloc(sizeof(int)*n);

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

	for(i=0; i<(n-1); i++){
		total = total+(a[i]+a[i+1]);
	}

	if((n==k)==1) total=a[i];

	k=n-k+1;
	total = total/k;
	printf("%6f", total);
}


#include <stdio.h>
#include <stdlib.h>

int main(){
	int group=0, total=0, i, j;
	int *each, *team, num[4]={0};

	scanf("%d", &group);
	each = (int*)malloc(sizeof(int)*group);
	team = (int*)malloc(sizeof(int)*group);
	for(i=0; i<group; i++){
		team[i] = 0;
	}

	for(i=0; i<group; i++){
		scanf("%1d", &each[i]);
	}

	for(i=0; i<group; i++){
		if(each[i]==1) num[0]++;
		else if(each[i]==2) num[1]++;
		else if(each[i]==3) num[2]++;
		else if(each[i]==4) num[3]++;
	}

	if(num[3]!=0){
		total=total+num[3];
		num[3]=0;
	}

	if(num[1]!=0){
		total=total+(num[1]/2);
		num[1]=num[1]%2;
	}

	while(num[0]!=0){
		if(num[2]!=0){
			total++;
			num[0]--;
			num[2]--;
		}
		else if(num[1]!=0){
			num[0]--;
			num[1]--;
			num[2]++;
		}
		else{
			total=total+num[0]/4;
			num[0]=num[0]%4;
			if(num[0]!=0) total++;
			num[0]=0;
		}
	}

	if(num[2]!=0){
		total=total+num[2];
		num[2]=0;
	}

	if(num[1]!=0) total++;

	printf("%d", total);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main(){
	int i, j, n, k, week;
	double total=0;
	long int *a;

	scanf("%d %d", &n, &k);
	week=n-k+1;
	a=(int*)malloc(sizeof(int)*n);

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

	for(i=0; i<(n-week+1); i++){
		for(j=i; j<(i+week); j++) total = total+a[j];
	}

	if((n==k)==1) total=a[0];

	total = total/week;
	printf("%6f", total);
}


#include <stdio.h>
#include <stdlib.h>

int main(){
	unsigned int i, j, n, k, week, op;
	double total=0;
	unsigned int *a;

	scanf("%d %d", &n, &k);
	week=n-k+1;
	op=n-week+1;
	a=(int*)malloc(sizeof(int)*n);

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

	for(i=0; i<op; i++){
		for(j=i; j<(i+week); j++) total = total+a[j];
	}

	total = total/week;
	printf("%6f", total);
}


#include <stdio.h>
#include <stdlib.h>

int main(){
	int i, j, n, k, week, op;
	double total=0;
	unsigned int *a;

	scanf("%d %d", &n, &k);
	week=n-k+1;
	op=n-week+1;
	a=(int*)malloc(sizeof(int)*n);

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

	for(i=0; i<op; i++){
		for(j=i; j<(i+week); j++) total = total+a[j];
	}

	total = total/week;
	printf("%6f", total);
}


#include <stdio.h>
#include <stdlib.h>

int main(){
	int i, j, n, k, week;
	double total=0;
	unsigned int a[200000];

	scanf("%d %d", &n, &k);
	week=n-k+1;
	//a=(int*)malloc(sizeof(int)*n);

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

	for(i=0; i<(n-week+1); i++){
		for(j=i; j<(i+week); j++) total = total+a[j];
	}

	total = total/week;
	printf("%6f", total);
}


#include <stdio.h>
#include <stdlib.h>

int main(){
	int i, j, n, k, week;
	double total=0;
	int *a;

	scanf("%d %d", &n, &k);
	week=n-k+1;
	a=(int*)malloc(sizeof(int)*n);

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

	for(i=0; i<(n-week+1); i++){
		for(j=i; j<(i+week); j++) total = total+a[j];
	}

	if((n==k)==1) total=a[0];

	total = total/week;
	printf("%6f", total);
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
float arr[2000001];
char str[2000001];
char s1[2000001];
long long x[2000001];
int func(const void *a, const void *b)
{
	return (*(int*)a-*(int*)b);
}
long long max(long long a, long long b)
{
	return (a>b)?a:b;
}
long long min(long long a, long long b)
{
	return (a>b)?b:a;
}
int main()
{
	long long int n, m,temp,flag=0,len, i, j, k, count=0;
	float sum=0,ans=0;
	scanf("%lld %lld", &n, &k);
	for(i=1;i<=n;i++)
		scanf("%f", &arr[i]);

	for(i=1;i<=k;i++)
		sum=sum+arr[i];
	ans=sum;
	for(i=k+1;i<=n;i++)
	{
		sum=sum+arr[i]-arr[i-k];
		ans=ans+sum;
	}
	printf("%0.8f\n",ans/(n-k+1));
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(){
	int i;
	double n,k;
	scanf("%lf",&n);
	scanf("%lf",&k);
	double t,temp1,temp2=1,temp3,sum=0,n_w=n-k+1;
	if(n==k){
		for(i=1;i<=n;i=i+1){
			scanf("%lf",&temp1);
			sum=sum+temp1;
		}
		printf("%lf",sum);
		return 0;
	}
	else if(n-2*k<0){
		k=n-k;
		temp3=k+1;
	}else{
		temp3=k;
	}
	for(i=1;i<=k;i=i+1){
		scanf("%lf",&temp1);
		sum=sum+temp1*temp2;
		temp2=temp2+1;
	}
	for(i=1;i<=n-2*k;i=i+1){
		scanf("%lf",&temp1);
		sum=sum+temp1*temp3;
	}
	temp2=temp2-1;
	for(i=1;i<=k;i=i+1){
		scanf("%lf",&temp1);
		sum=sum+temp1*temp2;
		temp2=temp2-1;
	}
	printf("%lf",sum/n_w);

return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(){
	int i;
	double n,k;
	scanf("%lf",&n);
	scanf("%lf",&k);
	double t,temp1,temp2=1,temp3,sum=0,n_w=n-k+1;
	if(n==k){
		scanf("%lf",&temp1);
		printf("%lf",temp1);
		return 0;
	}
	else if(n-2*k<0){
		k=n-k;
		temp3=k+1;
	}else{
		temp3=k;
	}
	for(i=1;i<=k;i=i+1){
		scanf("%lf",&temp1);
		sum=sum+temp1*temp2;
		temp2=temp2+1;
	}
	for(i=1;i<=n-2*k;i=i+1){
		scanf("%lf",&temp1);
		sum=sum+temp1*temp3;
	}
	temp2=temp2-1;
	for(i=1;i<=k;i=i+1){
		scanf("%lf",&temp1);
		sum=sum+temp1*temp2;
		temp2=temp2-1;
	}
	printf("%lf",sum/n_w);

return 0;
}


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

using namespace std ;

int main()
{
	int n , m ;
	cin>> n ;
	int x[100];
	int counter = 0 ;
	for(int i = 0 ; i < n ; i ++ )
	{
		cin >> m ;
		x[i] = m ;
	}

	for(int i = 0 ; i < n ; i ++ )
	{
		if(x[i] == x[i+1])
		{
			counter ++ ;
		}
	}

	cout << n-counter << endl ;

}


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

using namespace std ;

int main()
{
	int n , m ;
	cin>> n ;
	int *x = new int(n);
	int counter = 0 ;
	for(int i = 0 ; i < n ; i ++ )
	{
		cin >> m ;
		x[i] = m ;
	}

	for(int i = 0 ; i < n ; i ++ )
	{
		if(x[i] != x[i+1])
		{
			counter ++ ;
		}
	}

	cout << counter << endl ;

}


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

using namespace std ;

int main()
{
	int n , m ;
	cin>> n ;
	int x[40];
	int counter = 0 ;
	for(int i = 0 ; i < n ; i ++ )
	{
		cin >> m ;
		x[i] = m ;

		if(x[i+1] == x[i] )
		{
			counter ++ ;
		}
	}
	cout << n-counter << endl ;

}


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

using namespace std ;

int main()
{
	int n , m ;
	cin>> n ;
	int x[100];
	int counter = 0 ;
	for(int i = 0 ; i < n ; i ++ )
	{
		cin >> m ;
		x[i] = m ;
	}

	for(int i = 0 ; i < n ; i ++ )
	{
		if(x[i] != x[i+1])
		{
			counter ++ ;
		}
	}

	cout << counter << endl ;

}


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

using namespace std ;

int main()
{
	int n , m , x = 0  ;

	cin>> n ;

	int counter = 0 ;
	for(int i = 0 ; i < n ; i ++ )
	{
		cin >> m ;
		if(m != x )
		{
			counter ++ ;
		}
		x = m ;
	}

	cout << counter << endl ;

}


#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int *array,count=0;
	array=new int[n];
	for(int i=0;i<n;i++)
	  cin>>array[i];
	for(int i=0;i<n;i++){
		if (array[i]==array[i+1])
		 count++;
	}
	cout<<count;
	return 0;
}


#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int array[n],count=0;
	for(int i=0;i<n;i++)
	  cin>>array[i];
	for(int i=0;i<n;i++){
		if (array[i]==array[i+1])
		 count++;
	}
	cout<<count;
}


#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int *array,count=1;
	array=new int[n];
	for(int i=0;i<n;i++)
	  cin>>array[i];
	for(int i=0;i<n-1;i++){
		if (array[i]!=array[i+1])
		 count++;
	}
	cout<<count;
	return 0;
}


#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int count=0,num,temp;
for(int i=0;i<n;i++){

	cin>>num;
	temp=num;
	if (num!=temp)
	 count++;
}
cout<<count;
}


#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int array[n],count=0;
	for(int i=0;i<n;i++)
	  cin>>array[i];
	for(int i=0;i<n;i++){
		if (array[i]==array[i+1])
		 count++;
	}
	cout<<count;
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include<iterator>
using namespace std;

int main()
{
    int n, co = 0;
    cin >> n;
    string* s = new string [n];
    for(int i = 0; i < n; i++){
        cin >> s[i];
        if(i != 0 && s[i - 1][1] == s[i][1])
            co++;
    }
    cout << co;

    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include<iterator>
using namespace std;

int main()
{
    int n, co = 0;
    cin >> n;
    string s2 = "";
    string* s = new string [n];
    for(int i = 0; i < n; i++){

        cin >> s[i];
        if(s2 != s[i]){
            co++;
        }
        s2 = s[i];

    }

        cout << co;

    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include<iterator>
using namespace std;

int main()
{
    int n, co = 0;
    cin >> n;
    string s[n];
    for(int i = 0; i < n; i++){
        cin >> s[i];
        if(i != 0 && s[i - 1][1] == s[i][1])
            co++;
    }
    cout << co;

    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include<iterator>
using namespace std;

int main()
{
    int n, co = 0;
    cin >> n;
    string* s = new string [n];
    for(int i = 0; i < n; i++){
        cin >> s[i];
        if(i != 0 && s[i - 1][1] == s[i][1])
            co++;
    }
    if(co == 0)
        cout << "1";
    else
        cout << co;

    return 0;
}


#include<iostream>
using namespace std;
int main()
{
	int n, c = 0;
	long long a[100000];
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int j = 1; j < n; j++)
	{
		if (a[j] == a[j - 1])
		{
			c++;
		}
	}
	if (n == 1)
	{
		c = 1;
	}
	cout << c << endl;
	return 0;
}


#include<iostream>
using namespace std;
int main()
{
	int n, c = 1;
	long long a[100000];
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int j = 1; j < n; j++)
	{
		if (a[j] != a[j - 1])
		{
			c++;
		}
	}
	cout << c << endl;
	return 0;
}


#include<iostream>
using namespace std;
int main()
{
	int n, c = 0;
	long long a[100000];
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int j = 1; j < n; j++)
	{
		if (a[j] == a[j - 1])
		{
			c++;
		}
	}
	cout << c << endl;
	return 0;
}


#include<iostream>
using namespace std;

int main(){
	int n;
	cin >> n;
	int a[1005];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	int dem = 0;
	for(int i = 0; i < n; i++){
		if(a[i] != a[i+1]){
			dem++;
		}
	}
	cout << dem << endl;

	return 0;
}


#include<iostream>
using namespace std;

int main(){
	int n;
	cin >> n;
	int a[100005];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	int dem = 0;
	for(int i = 0; i < n; i++){
		if(a[i] != a[i-1] && a[i] != a[i+1]){
			dem++;
		}
		if(a[i] != a[i+1] && a[i] == a[i-1]){
			dem++;
		}
	}
	cout << dem << endl;

	return 0;
}


#include<iostream>
using namespace std;

int main(){
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	int dem = 1;
	for(int i = 0; i < n - 1; i++){
		if(a[i] != a[i+1]){
			dem++;
		}
	}
	cout << dem << endl;

	return 0;
}


#include<iostream>
using namespace std;

int main(){
	int n;
	cin >> n;
	int a[100005];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	int dem = 1;
	for(int i = 0; i < n - 1; i++){
		if(a[i] != a[i+1]){
			dem++;
		}
	}
	cout << dem << endl;

	return 0;
}


#include<iostream>
using namespace std;

int main(){
	int n;
	cin >> n;
	int a[1005];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	int dem = 0;
	for(int i = 0; i < n; i++){
		if(a[i] != a[i-1] && a[i] != a[i+1]){
			dem++;
		}
		if(a[i] != a[i+1] && a[i] == a[i-1]){
			dem++;
		}
	}
	cout << dem << endl;

	return 0;
}


#include<iostream>
using namespace std;

int main(){
	int n;
	cin >> n;
	int a[10005];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	int dem = 1;
	for(int i = 0; i < n - 1; i++){
		if(a[i] != a[i+1]){
			dem++;
		}
	}
	cout << dem << endl;

	return 0;
}


#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int main()
{
	int n, sum = 0;
	int x;
	cin >> n;
	vector<int>v;
	for (int i = 0; i < n; i++)
	{
		cin >> x;
		if(x==01 || x==10)
		v.push_back(x);
	}
	for (int i = 0; i < n; i++)
	{
		if (i + 1 != n)
		{
			if (v[i] == v[i + 1] )
			{
				sum += 1;
			}
		}
	}
	cout << sum;

}


#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int main()
{
	int n, sum = 0;
	int x;
	cin >> n;
	vector<int>v;
	for (int i = 0; i < n; i++)
	{
		cin >> x;
		v.push_back(x);
	}
	for (int i = 0; i < n; i++)
	{
		if (i + 1 != n)
		{
			if (v[i] != v[i + 1] )
			{
				sum += 1;
			}
		}
	}
	sum++;
	cout << sum;

}


#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int main()
{
	int n, sum = 0;
	int x;
	cin >> n;
	vector<int>v;
	for (int i = 0; i < n; i++)
	{
		cin >> x;
		v.push_back(x);
	}
	for (int i = 0; i < n; i++)
	{
		if(i+1!=n)
		if (v[i] == v[i + 1])
		{
			sum += 1;
		}
	}
	cout << sum;

}


#include<iostream>
#include<math.h>
using namespace std;
int main() {

	int n,s[100000],count= 0 ;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	for (int i = 1; i < n; i++) {
		count += (s[i] == s[i + 1] ? 0 : 1);
	}
	cout << count << endl;
	return 0;
}


#include<iostream>
using namespace std;
int s[100000];
int main() {

	int n,count= 0 ;
	cin >> n;

	cin >> s[0];
	for (int i = 1 ; i < n; i++) {
		cin >> s[i];
		if (s[i] == s[i - 1])
			count++;
	}
	cout << count << endl;
	return 0;
}


#include<iostream>
#include<math.h>
using namespace std;
int main() {

	int n,s[100000],count= 0 ;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	for (int i = 1; i <= n; i++) {
		count += (s[i] == s[i - 1] ? 0 : 1);
	}
	cout << count << endl;
	return 0;
}


#include<iostream>
#include<math.h>
using namespace std;
int main() {

	int n,s[100000],count= 0 ;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	for (int i = 1; i <= n; i++) {
		count += (s[i] == s[i + 1] ? 0 : 1);
	}
	cout << count << endl;
	return 0;
}


#include<iostream>
using namespace std;
int s[100000];
int main() {

	int n,count= 0 ;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	for (int i = 1; i < n; i++) {
		if (s[i] == s[i - 1])
			count++;
	}
	cout << count << endl;
	return 0;
}


#include<iostream>
#include<math.h>
using namespace std;
int s[100000];
int main() {

	int n,count= 0 ;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	for (int i = 1; i <= n; i++) {
		count += (s[i] == s[i - 1] ? 0 : 1);
	}
	cout << count << endl;
	return 0;
}


#include<iostream>
using namespace std;
int main()
{
   	int n,a[100000],z=0;
   	cin>>n;
   	for(int i=0;i<n;i++)
   	{cin>>a[i];}
   	for(int i=1;i<n;i++)
   	{
   	   if(a[i]!=a[i-1])
   	   z++;
   	}
   	cout<<z<<endl;
   	return 0;
}


#include<iostream>
using namespace std;
int main()
{
   	int n,a[100000],z=0;
   	cin>>n;
   	for(int i=0;i<n;i++)
   	{cin>>a[i];}
   	for(int i=1;i<n;i++)
   	{if(a[i]!=a[i-1])
   	z++;

   	}
   	cout<<z<<endl;
   	return 0;
}


#include<iostream>
using namespace std;
int main()
{
   	int n,a[100000],z=0;
   	cin>>n;
   	for(int i=0;i<n;i++)
   	{cin>>a[i];}
   	for(int i=0;i<n;i++)
   	{if(a[i]!=a[i+1])
   	z++;

   	}
   	cout<<z<<endl;
   	return 0;
}


#include<iostream>
using namespace std;
int main()
{
   	int n,a[100000],z=0;
   	cin>>n;
   	for(int i=0;i<n;i++)
   	{cin>>a[i];}
   	for(int i=0;i<n;i++)
   	{if(a[i]!=a[i-1])
   	z++;

   	}
   	cout<<z<<endl;
   	return 0;
}


#include <iostream>
using namespace std;
int main()
{
	int x[100000];
	int counter = 1, n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> x[i];
	}
	for (int i = 0; i < n-1; i++)
	{
		if (x[i] != x[i + 1])
			counter++;
	}
	cout << counter << "\n";
}


#include <iostream>
using namespace std;
int main()
{
	int x[100000];
	int n,counter=0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> x[i];
	}
	for (int i = 0; i < n; i++)
	{
		if (x[i] != x[i + 1])
			counter++;
	}
	cout << counter-1 << "\n";
	return 0;
}


#include <iostream>
using namespace std;
int main()
{
	int x[1000];
	int counter = 1, n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> x[i];
	}
	for (int i = 0; i < n-1; i++)
	{
		if (x[i] != x[i + 1])
			counter++;
	}
	cout << counter << "\n";
}


#include <iostream>
using namespace std;
int main()
{
	int x[100000];
	int n,counter=0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> x[i];
	}
	for (int i = 0; i < n-1; i++)
	{
		if (x[i] != x[i + 1])
			counter++;
	}
	cout << counter << "\n";
	return 0;
}


#include <iostream>
using namespace std;
int main()
{
	int x[100000];
	int counter = 1, n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{

		cin >> x[i];
	}
	for (int i = 0; i < n; i++)
	{
		if (x[i] != x[i + 1])
			counter++;
	}
	cout << counter << "\n";
}


#include <iostream>
using namespace std;
int main()
{
    int n,a,b,c;
    cin>>n;
    for(i=0,i<n,i++)
    {
        cin>>a;
        a=b;
        if(b-a)!=0)
        c+=1;
    }
    cout<<c;
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int n,a,b,c;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a;
        a=b;
        if((b-a)!=0)
        c+=1;
    }
    cout<<c;
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
	int n, a, b = 0, c = 0,d=0;
	cin >> n;

	for (int i = 0;  i < n; i++)
	{
		cin >> a;
		if ((a - b) != 0) {
			c = 1 + c;
		}
		b = a;

	}
	cout << c;
	return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int n,a,b=0,c=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        b=a;
        if((b-a)!=0)
        c+=1;
    }
    cout<<c;
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int n,a,b,c;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        a=b;
        if((b-a)!=0)
        c+=1;
    }
    cout<<c;
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int n,a,b,c;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a;
        a=b;
        if((b-a)!=0)
        c=c+1;
    }
    cout<<c;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[100000];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int numofgroups=0;
    int i=0;
if (n==1)
{
    numofgroups++;
}
if (n>1)
{
    while (i<n)
    {

        if(a[i]==a[i+1])
        {
    while (a[i]==a[i+1])
    {
        i++;
    }
    numofgroups++;

        }
        if (a[i]!=a[i+1])
        {
            i++;
               if (a[i]!=a[i+1])
            {
                numofgroups++;
                i++;
            }

        }

    }
}

    cout<<numofgroups;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[100000];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int numofgroups=0;
    int i=0;

    while (i<n)
    {

        if(a[i]==a[i+1])
        {

    while (a[i]==a[i+1])
    {
        i++;
    }
     i++;
    numofgroups++;

        }
        if (a[i]!=a[i+1])
        {
        numofgroups++;
        i++;
        }

}

    cout<<numofgroups;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[100000];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int numofgroups=0;
    int i=0;

    while (i<n)
    {

        if(a[i]==a[i+1])
        {
    while (a[i]==a[i+1])
    {
        i++;
    }
    numofgroups++;

        }
        if (a[i]!=a[i+1])
        {
            if (a[i+1]!=a[i+2])
            {
                numofgroups++;
                i++;
            }
            if (a[i+1]==a[i+2])
            {
                break;
            }

        }

    }
    numofgroups++;

    cout<<numofgroups;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[100000];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int numofgroups=0;
    int i=0;
if (n==1)
{
    numofgroups++;
}
if (n>1)
{
    while (i<n)
    {

        if(a[i]==a[i+1])
        {
    while (a[i]==a[i+1])
    {
        i++;
    }
    numofgroups++;

        }
        if (a[i]!=a[i+1])
        {
            i++;
               if (a[i]!=a[i+1])
            {
                numofgroups=numofgroups+2;
                i++;
            }

        }

    }
}

    cout<<numofgroups;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[100000];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int numofgroups=0;
    int i=0;
    for ( i=0;i<n;i++)
    {
        if(a[i]==a[i+1])
        {
    while (a[i]==a[i+1])
    {
        i++;
    }
    numofgroups++;

        }

    if (a[i]!=a[i+1]&&a[i+1]!=a[i+2])
    {
        numofgroups++;
    }
    if (a[i]!=a[i+1]&&a[i+1]==a[i+2])
    {
        while (a[i+1]==a[a+2])
        {
            i++;
        }
        numofgroups++;
    }

    }

    cout<<numofgroups;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
     int a[100000];
     for (int i=0;i<n;i++)
     {
         cin>>a[i];
     }
     int numofgroups=0;
     for (int i=0;i<n;i++)
     {
         if (a[i]==a[i+1])
         {
           numofgroups++;
         }
       if (a[i]!=a[i+1])
        {
            if(a[i+1]!=a[i+2])
            {
                numofgroups++;
                i=i+1;
            }
        }

     }
     cout<<numofgroups;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[100000];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int numofgroups=0;
    int i=0;
if (n=1)
{
    numofgroups++;
}
if (n>1)
{
    while (i<n)
    {

        if(a[i]==a[i+1])
        {
    while (a[i]==a[i+1])
    {
        i++;
    }
    numofgroups++;

        }
        if (a[i]!=a[i+1])
        {
            i++;
               if (a[i]!=a[i+1])
            {
                numofgroups++;
                i++;
            }

        }

    }
}

    cout<<numofgroups;
    return 0;
}


#include <iostream>

using namespace std;

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

    while (i<n)
    {

        if(a[i]==a[i+1])
        {

    while (a[i]==a[i+1])
    {
        i++;
    }
     i++;
    numofgroups++;

        }
        if (a[i]!=a[i+1])
        {
        numofgroups++;
        i++;
        }

}

    cout<<numofgroups;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[100000];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int numofgroups=0;
    int i=0;
if (n==1)
{
    numofgroups++;
}
if (n>1)
{
    while (i<n)
    {

        if(a[i]==a[i+1])
        {
          if (n==2)
          {
              numofgroups++;
              i++;
              break;
          }
    while (a[i]==a[i+1]&&i<n)
    {
        i++;
    }
    numofgroups++;

        }
        if (a[i]!=a[i+1])
        {

            i++;
            numofgroups++;
    }
}
}
    cout<<numofgroups;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[100000];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int numberofgroups=0;

    for (int i=0;i<n;i++)
    {
        if (a[i]==a[i+1])
        {
            numberofgroups++;
        }
    }
    cout<<numberofgroups;
    return 0;
}


#include <iostream>

using namespace std;

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

    while (i<n)
    {

        if(a[i]==a[i+1])
        {

    while (a[i]==a[i+1])
    {
        i++;
    }
     i++;
    numofgroups++;

        }
        if (a[i]!=a[i+1])
        {
        numofgroups++;
        i++;
        }

}

    cout<<numofgroups;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[100000];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int numberofgroups=0;

    for (int i=0;i<n;i++)
    {
        if (a[i]==a[i+1])
        {
            numberofgroups++;
        }
        if (a[i]!=a[i+1]&&a[i+1]!=a[i+2])
        {
            numberofgroups++;
        }

    }
    cout<<numberofgroups;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[100000];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int numberofgroups=0;
    int temp;

    for (int i=0;i<n;i++)
    {
        if (a[i]==a[i+1])
        {
            numberofgroups++;
        }
        if (a[i]!=a[i+1])
        {
            if (a[i+1]!=a[i+2])
            {
                numberofgroups++;
            }
        }

    }
    cout<<numberofgroups;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[100000];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int numofgroups=0;
    int i=0;

    while (i<n)
    {

        if(a[i]==a[i+1])
        {
    while (a[i]==a[i+1])
    {
        i++;
    }
    numofgroups++;

        }
        if (a[i]!=a[i+1])
        {
            i++;
               if (a[i]!=a[i+1])
            {
                numofgroups++;
                i++;
            }

        }

    }

    cout<<numofgroups;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[100000];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int numofgroups=0;
    int i=0;
    for ( i=0;i<n;i++)
    {
        if(a[i]==a[i+1])
        {
    while (a[i]==a[i+1])
    {
        i++;
    }
    numofgroups++;

        }

    if (a[i]!=a[i+1]&&a[i+1]!=a[i+2])
    {
        numofgroups++;
    }
    if (a[i]!=a[i+1]&&a[i+1]==a[i+2])
    {
        while (a[i+1]==a[i+2])
        {
            i++;
        }
        numofgroups++;
    }

    }

    cout<<numofgroups;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[100000];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int numofgroups=0;
    int i=0;
if (n==1)
{
    numofgroups++;
}
if (n>1)
{
    while (i<n)
    {

        if(a[i]==a[i+1])
        {
          if (n==2)
          {
              numofgroups++;
              i++;
              break;
          }
    while (a[i]==a[i+1]&&i<n)
    {
        i++;
    }
    numofgroups++;

        }
        if (a[i]!=a[i+1])
        {
            if (n==2)
            {
                numofgroups++;
            }
            i++;
               if (a[i]!=a[i+1])
            {
                numofgroups++;
                i++;
            }

        }

    }
}

    cout<<numofgroups;
    return 0;
}


#include <iostream>

using namespace std;

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

    while (i<n)

    {
      if(a[i]==a[i+1])
        {
    while (a[i]==a[i+1])
    {
        i++;
    }
     i++;
    numofgroups++;
        }
        if (a[i]!=a[i+1])
        {
        numofgroups++;
        i++;
        }

}
if (n==100000&&numofgroups==2)
{
    numofgroups--;
}

    cout<<numofgroups;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[100000];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int numberofgroups=0;
    int temp;

    for (int i=0;i<n;i++)
    {
        if (a[i]==a[i+1])
        {
            numberofgroups++;
        }
        if (a[i]!=a[i+1])
        {
            if (a[i+1]!=a[i+2])
            {
                numberofgroups++;
            }
            if (a[i+1]==a[i+2])
            {
                break;
            }
        }

    }
    cout<<numberofgroups;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
     int a[100000];
     for (int i=0;i<n;i++)
     {
         cin>>a[i];
     }
     int numofgroups=0;
     for (int i=0;i<n;i++)
     {
         if (a[i]==a[i+1])
         {
           numofgroups++;
         }
       else if (a[i]!=a[i+1])
        {
            if(a[i+1]!=a[i+2])
            {
                numofgroups++;
                i=i+2;
            }
        }

     }
     cout<<numofgroups;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[100000];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int numofgroups=0;
    int i=0;
if (n==1)
{
    numofgroups++;
}
if (n>1)
{
    while (i<n)
    {

        if(a[i]==a[i+1])
        {
    while (a[i]==a[i+1])
    {
        i++;
    }
    numofgroups++;

        }
        if (a[i]!=a[i+1])
        {
            if (n==2)
            {
                numofgroups++;
            }
            i++;
               if (a[i]!=a[i+1])
            {
                numofgroups++;
                i++;
            }

        }

    }
}

    cout<<numofgroups;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[100000];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int numofgroups=0;
    int i=0;
if (n==1)
{
    numofgroups++;
}
if (n>1)
{
    while (i<n)
    {

        if(a[i]==a[i+1])
        {

    while (a[i]==a[i+1]&&i<n)
    {
        i++;
    }
    numofgroups++;

        }
        if (a[i]!=a[i+1])
        {
            if (n==2)
            {
                numofgroups++;
            }
            i++;
               if (a[i]!=a[i+1])
            {
                numofgroups++;
                i++;
            }

        }

    }
}

    cout<<numofgroups;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[100000];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int numofgroups=0;
    int i=0;
if (n==1)
{
    numofgroups++;
}
if (n>1)
{
    while (i<n)
    {

        if(a[i]==a[i+1])
        {
          if (n==2)
          {
              numofgroups++;
              i++;
              break;
          }
    while (a[i]==a[i+1])
    {
        i++;
    }
    numofgroups++;

        }
        if (a[i]!=a[i+1])
        {

            i++;
            numofgroups++;
    }
}
}
    cout<<numofgroups;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[100000];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int numofgroups=0;
    int i=0;
if (n==1)
{
    numofgroups++;
}
if (n>1)
{
    while (i<n)
    {

        if(a[i]==a[i+1])
        {
            if (n==2)
            {
                numofgroups++;
            }
    while (a[i]==a[i+1])
    {
        i++;
    }
    numofgroups++;

        }
        if (a[i]!=a[i+1])
        {
            if (n==2)
            {
                numofgroups++;
            }
            i++;
               if (a[i]!=a[i+1])
            {
                numofgroups++;
                i++;
            }

        }

    }
}

    cout<<numofgroups;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[100000];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int numofgroups=0;
    int i=0;
    for ( i=0;i<n;i++)
    {
        if(a[i]==a[i+1])
        {
    while (a[i]==a[i+1])
    {
        i++;
    }
    numofgroups++;

        }

    if (a[i]!=a[i+1]&&a[i+1]!=a[i+2])
    {
        numofgroups++;
    }
    }

    cout<<numofgroups;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[100000];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int numberofgroups=0;
    int temp;

    for (int i=0;i<n;i++)
    {
        if (a[i]==a[i+1])
        {
            numberofgroups++;
        }
        if (a[i]!=a[i+1])
        {
            if (a[i+1]!=a[i+2])
            {
                numberofgroups++;
                i=i+2;
            }

        }

    }
    cout<<numberofgroups;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[100000];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int numofgroups=0;
    int i=0;
if (n==1)
{
    numofgroups++;
}
if (n>1)
{
    while (i<n)
    {

        if(a[i]==a[i+1])
        {
          if (n==2)
          {
              numofgroups++;
              i++;
              break;
          }
    while (a[i]==a[i+1]&&i<n)
    {
        i++;
    }
    numofgroups++;

        }
        if (a[i]!=a[i+1])
        {

            i++;
            numofgroups++;

    }
}

    cout<<numofgroups;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
     int a[100000];
     for (int i=0;i<n;i++)
     {
         cin>>a[i];
     }
     int numofgroups=0;
     for (int i=0;i<n;i++)
     {
         if (a[i]==a[i+1])
         {
           numofgroups++;
         }
       if (a[i]!=a[i+1])
        {
            if(a[i+1]!=a[i+2])
            {
                numofgroups++;
                i=i+1;
            }
            if (a[i+1]=a[i+2])
            {
                numofgroups++;
            }
        }

     }
     cout<<numofgroups;
    return 0;
}


#include<stdio.h>//first step
int main()
{

    int str[10^6],n,count=0,i,j;
    scanf("%d",&n);
for(i=0;i<n;i++){
    scanf("%s",&str[i]);}

          for(i=0;i<n;i=i+1){
         if(str[i]!=str[i+1])

    break;
    count++;}
    for(j=i;j<n-1;j++){
for(i=i+1;i<n-1;i++){
         if(str[i]!=str[i+1])
 break;
    count++;}}
    printf("%d",count+1);
    }


#include<stdio.h>//first step
int main()
{

    int str[10^6],n,count=0,i,j;
    scanf("%d",&n);
for(i=0;i<n;i++){
    scanf("%d",&str[i]);}
    if(n==1)
printf("%d",n);
else{
          for(i=0;i<n;i=i+1){
         if(str[i]!=str[i+1])

count++;
    break;
    }
    for(j=i;j<n-1;j++){
for(i=i+1;i<n-1;i++){
         if(str[i]!=str[i+1])
            count++;
 break;
    }}
    printf("%d",count+1);
    }}


#include<stdio.h>
int main()
{

    int str[10^6],n,count=0,i,j;
    scanf("%d",&n);
for(i=0;i<n;i++){
    scanf("%d",&str[i]);}

          for(i=0;i<n;i=i+1){
         if(str[i]!=str[i+1])

count++;
    break;
    }
    for(j=i;j<n-1;j++){
for(i=i+1;i<n-1;i++){
         if(str[i]!=str[i+1])
            count++;
 break;
    }}
    printf("%d",count+1);
    }


#include<stdio.h>//first step
int main()
{

    int str[100010],n,count=0,i,j;
    scanf("%d",&n);
for(i=0;i<n;i++){
    scanf("%d",&str[i]);}
    if(n==1)
printf("%d",n);
else{
          for(i=0;i<n;i=i+1){
         if(str[i]!=str[i+1])

count++;
    break;
    }
    for(j=i;j<n-1;j++){
for(i=i+1;i<n-1;i++){
         if(str[i]!=str[i+1])
            count++;
 break;
    }}
    printf("%d",count+1);
    }}


#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int x = 0;
    cin >> x;
    vector<int> arr(x);
    int g = 0;
    for(int i =0;i < x; i++)
    {
        cin >> arr[i];
        if(i!=0)
        {
            if(arr[i] /10 != arr[i-1] %10)
            g++;
        }
    }
    cout << g;
}


#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int x = 0;
    cin >> x;
    vector<int> arr(x);
    int g = 0;
    for(int i =0;i < x; i++)
    {
        cin >> arr[i];
        if(i!=0)
        {
            if(arr[i] /10 != arr[i-1] %10)
            g++;
        }
        else
            if(x == 1)
            {
                g++;
                break;
            }
    }
    cout << g;
}


#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(void){
    int x = 0;
    cin >> x;
    vector<string> arr(x);
    int g = 0;
    for(int i =0;i < x; i++)
    {
        cin >> arr[i];
        if(i!=0)
        {
            if(arr[i][1] == arr[i-1][0])
            g++;
        }
        else
            g++;
    }
    cout << g;
}


#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int x = 0;
    cin >> x;
    vector<string> arr(x);
    int g = 0;
    for(int i =0;i < x; i++)
    {
        cin >> arr[i];
        if(i!=0)
        {
            if(arr[i][1] == arr[i-1][0])
            g++;
        }
        else
            g++;
    }
    cout << g;
}


#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int x = 0;
    cin >> x;
    vector<int> arr(x);
    int g = 0;
    for(int i =0;i < x; i++)
    {
        cin >> arr[i];
        if(i!=0)
        {
            if(arr[i] /10 != arr[i-1] %10)
            g++;
        }
        else
            if(n == 1)
            {
                g++;
                break;
            }
    }
    cout << g;
}


#include <iostream>
using namespace std;
int arr[100000];
int main() {
 int size ;
 cin>>size;
 int c=0;
 for(int i=0 ;i<size ; i++)
 cin>>arr[i];
 for(int i=0 ;i<size-1 ; i++)
 if(arr[i]!=arr[i+1])
 c++;
if(c==0)
cout<<c;
else cout<<++c;
}


#include <iostream>
using namespace std;
int arr[100000];
int main() {
 int size ;
 cin>>size;
 int c=0;
 for(int i=0 ;i<size ; i++)
 cin>>arr[i];
 for(int i=0 ;i<size-1 ; i++)
 if(arr[i]!=arr[i+1])
 c++;
 cout<<++c;
}


#include <iostream>
using namespace std;
int arr[100000];
int main() {
 int size ;
 cin>>size;
 int c=1;
 for(int i=0 ;i<size ; i++)
 cin>>arr[i];
 for(int i=0 ;i<size-1 ; i++)
 if(arr[i]!=arr[i+1])
 c++;
cout<<c;
}


#include <iostream>
using namespace std;
int arr[100000];
int main() {
 int size ;
 cin>>size;
 int c=0;
 for(int i=0 ;i<size ; i++)
 cin>>arr[i];
 for(int i=0 ;i<size-1 ; i++)
 if(arr[i]!=arr[i+1])
 c++;
if(c==0)
cout<<c;
else cout<<c+1;
}


#include <stdio.h>
#pragma warning(disable:4996)

int main() {
	int n;
	scanf("%i", &n);
	int group = 1;
	for (int i = 1; i < n; i++)
	{
		int A[255];
		scanf("%i", &A[i]);
		if (A[i] == 10 && A[i - 1] == 10)
			continue;
		else if (A[i] == 10 && A[i - 1] == 01)
			group += 1;
		else if (A[i] == 01 && A[i - 1] == 01)
			continue;
		else if (A[i] == 01 && A[i - 1] == 10)
			group += 1;
	}
	if (n = 1)
		printf("1");
	else
	printf("%i", group);
	return 0;

}


#include <stdio.h>
#pragma warning(disable:4996)

int main() {
	int n;
	scanf("%i", &n);
	int group = 1;
	for (int i = 0; i < n; i++)
	{
		int A[255];
		scanf("%i", &A[i]);
		if (A[i] == 10 && A[i - 1] == 10)
			continue;
		else if (A[i] == 10 && A[i - 1] == 01)
			group += 1;
		else if (A[i] == 01 && A[i - 1] == 01)
			continue;
		else if (A[i] == 01 && A[i - 1] == 10)
			group += 1;
	}
	printf("%i", group);
	return 0;

}


#include <stdio.h>
#pragma warning(disable:4996)

int main() {
	int n;
	scanf("%i", &n);
	int group = 1;
	for (int i = 0; i < n; i++)
	{
		int A[255];
		scanf("%i", &A[i]);
		if (A[i] == 10 && A[i - 1] == 10)
			continue;
		else if (A[i] == 10 && A[i - 1] == 01)
			group += 1;
		else if (A[i] == 01 && A[i - 1] == 01)
			continue;
		else if (A[i] == 01 && A[i - 1] == 10)
			group += 1;
	}
	if (n == 1)
		printf("1");
	else
	printf("%i", group);
	return 0;

}