#include<stdio.h>
#include<string.h>

int num[1001][1001];
short int row[1005], col[1005];

int main(){
	int n,m,k,x,y,i,j;
	char c, s[10];
	scanf("%d%d%d",&n,&m,&k);
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			scanf("%d",&num[i][j]);
	for(i=1;i<=n;i++)row[i]=i;
	for(j=1;j<=m;j++)col[j]=j;
	while(k--){
		gets(s);
		scanf(" %c%d%d",&c,&x,&y);
		if(c=='c'){
			col[x]^=col[y];
			col[y]^=col[x];
			col[x]^=col[y];
		}
		else if(c=='r'){
			//printf("%d %d,",row[x],col[y]);
			row[x]^=row[y];
			row[y]^=row[x];
			row[x]^=row[y];
			//printf(" %d %d\n",row[x],col[y]);
		}
		else if(c=='g')printf("%d\n",num[row[x]][col[y]]);
	}
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define SORT(a,n) qsort(a,n,sizeof(int),intcmp)
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define fill(a,v)                   memset(a, v, sizeof(a))
int intcmp(const void *f,const void *s)
{
   return (*(int *)f-*(int *)s);
}
int gcd(int a,int b){ return ((b==0)?a:gcd(b,a%b));}

#define MAX  1024
#define MODBY 1000000007

typedef long long int lld;
typedef long double Lf;

int a[MAX][MAX];
void swap(int *x,int *y)
{
   int temp=*x;
   *x=*y;
   *y=temp;

}
int main()
{
   int cases;
   int i,j;
   int m,n,k;
   int row[MAX],col[MAX];
   int s,x,y;
   char in[10];
   scanf("%d",&n);
   scanf("%d",&m);
   scanf("%d",&k);
   for(i=1;i<=n;++i){
      for(j=1;j<=m;++j)
         scanf("%d",&a[i][j]);
      row[i]=i;
   }
   for(j=1;j<=m;++j)
      col[j]=j;
   while(k--){
      ss(in);s(x);s(y);
      s=in[0];
      if(s=='c')
         swap(&col[x],&col[y]);
      else if(s=='r')
         swap(&row[x],&row[y]);
      else printf("%d\n",a[row[x]][col[y]]);
   }
   return 0;
}


/*
ID: mohamma73
LANG: C
TASK: crypt1
*/

#include"stdio.h"
#include"stdlib.h"
#include"ctype.h"
#include"math.h"
#include"string.h"
struct cor{
	int real;
	int indx;
};
struct card{
	int val;
	char suit;
	int id;
};
struct point{
	int x;
	int y;
	int visit;
};
struct node{
	int id;
	int n;
	int nei[102];
};
struct person{
	int id;
	int nd;
	int nl;
	int like[2004];
	int dis[2004];
	int visit;
};
struct farmer{
	int p;
	int c;
};
void inc(int *a,int n){
	int i;
	if(a[0]!=2){
		a[0]++;
		return;
	}
	for(i=0;i<n && a[i]==2;i++)
		a[i]=0;
	if(i<n)
		a[i]++;
}
int cmp(char *s,char *t){
	int n=strlen(s);
	int m=strlen(t);
	int i,j;
	for(i=0,j=0;i<n && j<m && s[i]==t[j];i++,j++);
	if(s[i]>t[j])
		return 1;
	else if(s[i]<t[j])
		return -1;
	else
		return 0;

}
int getword(char *s,int n){
	int i;
	char c;
	while(isspace(c=getchar()));
	for(i=0;i<n && !isspace(c);i++,c=getchar())
		s[i]=c;
	s[i++]='\0';
	return i-1;
}
int fgetword(char *s,int n,FILE *fp){
	int i;
	char c;
	while(isspace(c=getc(fp)));
	for(i=0;i<n && !isspace(c) && c!=EOF;i++,c=getc(fp))
		s[i]=c;
	s[i++]='\0';
	return i-1;
}
long long atll(char *s){
	long long n=0;
	int i;
	for(i=0;s[i]!='\0';i++){
		n*=10;
		n+=(s[i]-'0');
	}
	return n;
}
int Bsear(char *s,char words[][13],int n){
	int l=0;
	int h=n;
	int mid;
	while(l<h){
		mid=(l+h)/2;
		if(cmp(words[mid],s)==0)
			return 1;
		else if(cmp(words[mid],s)==1){
			h=mid;
		}else
			l=mid+1;
	}
	return -1;
}
void func(int *n,int base,int num){
	int i=0;
	while(num/base!=0){
		n[i++]=num%base;
		num/=base;
	}
	n[i++]=num;
	n[i++]=20;
}
int pal(int *n){
	int i,j;
	for(i=0;n[i]!=20;i++);
	for(j=0;j<i/2 && n[j]==n[i-j-1];j++);
	if(j==i/2)
		return 1;
	return 0;
}
int ispal(char *s, int i, int j){
	int k;
	for(k=0;k<((j-i+1)/2) && s[i+k]==s[j-k];k++);
	if(k==(j-i+1)/2)
		return 1;
	return 0;
}
void insort(int *a,int n){
	int i,j,temp;
	for(i=1;i<n;i++){
		j=i;
		while(j>0 && a[j]<a[j-1]){
			temp=a[j-1];
			a[j-1]=a[j];
			a[j]=temp;
			j--;
		}
	}
}
char lower(char c){
	return c<'a'?c+('a'-'A'):c;
}
void sort(int *a,int n){
	int i,j,temp;
	for(i=1;i<n;i++)
		for(j=i;j>0 && a[j-1]>a[j];j--){
				temp=a[j];
				a[j]=a[j-1];
				a[j-1]=temp;

		}
}
void fun(int n,char *s){
	int i=0;
	for(i=0;n/10!=0;i++,n/=10)
		s[i]=n%10+'0';
	s[i++]=n+'0';
	s[i]='\0';
}
void sortIn(int *a,int *indx,int n){
	int t1;
	int i,j;
	for(i=1;i<n;i++)
		for(j=i;j>0 && a[j-1]>a[j];j--){
			t1=a[j-1];
			a[j-1]=a[j];
			a[j]=t1;
			t1=indx[j-1];
			indx[j-1]=indx[j];
			indx[j]=t1;
		}
}
int valid(int *a,int l,int r,int n){
	int f=0;
	if(l>0 && a[l-1]>a[r])
		f=1;
	if(a[l+1]<a[r])
		f=1;
	if(a[r-1]>a[l])
		f=1;
	if(r<n-1 && a[r+1]<a[l])
		f=1;
	if(f)
		return 0;
	return 1;
}
void change(char *stripe,int *colors,int idx,int k){
	int j=0;
	if(idx==1){
		if(stripe[0]-'A'>0)
			stripe[0]=colors[stripe[0]-'A'-1];
		else
			stripe[0]=colors[stripe[0]-'A'+1];
		return ;
	}
	for(j=0;j<idx;j+=2){
		if(stripe[j]-'A'>0){
			if(stripe[j]==stripe[j+1])
				stripe[j]=colors[stripe[j]-'A'-1];
			else if(stripe[j+1]!=colors[stripe[j]-'A'-1])
				stripe[j]=colors[stripe[j]-'A'-1];
			else if(stripe[j]-'A'<k-1)
				stripe[j]=colors[stripe[j]-'A'+1];
			else
				stripe[j]=colors[stripe[j]-'A'-2];
		}else{
			if(stripe[j]==stripe[j+1])
				stripe[j]=colors[stripe[j]-'A'+1];
			else
				stripe[j]=colors[stripe[j]-'A'+2];
		}
	}
}
int invite(struct point *nom[],int n,struct point *pts[],int m,struct point *invite[]){
	int i,j,idx=0;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			if(nom[i]->x==pts[j]->x || nom[i]->y==pts[j]->y){
				if(pts[j]->visit==0){
					invite[idx++]=pts[j];
					pts[j]->visit=1;
				}
			}
		}

	}
	return idx;
}
int feasible(struct person *a[],int n){
	int i,j,k;
	int flag=1;
	for(i=0;flag && i<n;i++)
		for(j=0;flag && j<a[i]->nd;j++)
			for(k=0;flag &&k<n;k++){
				if(a[k]->id==a[i]->dis[j]){
					flag=0;
					break;
				}
			}
	if(i==n)
		return 1;
	return 0;
}
int find(struct node *p,struct node *node[]){
	int i,j,k;
	int count=0;
	for(i=0;i<p->n;i++){
		if(p->nei[i]==-1)
			continue;
		for(j=0;j<node[p->nei[i]]->n;j++){
			if(node[p->nei[i]]->nei[j]==-1)
				continue;
			for(k=0;k<p->n;k++){
				if(p->nei[k]==-1)
					continue;
				if(node[p->nei[i]]->nei[j]==p->nei[k])
					count++;
			}
		}
	}

	return count;
}
void rem(struct node *p,struct node *nodes[],int n){
	int i,j;
	for(i=0;i<n;i++){
		if(nodes[i]==NULL)
			continue;
		for(j=0;j<nodes[i]->n;j++)
			if(nodes[i]->nei[j]==p->id)
				nodes[i]->nei[j]=-1;
	}
}
main(){
	char s[20];
	int e,i,j,temp;
	int w;
	char c;
	getword(s,20);
	int m=atoi(s);
	getword(s,20);
	int n=atoi(s);
	getword(s,20);
	int q=atoi(s);
	struct cor col[1004];
	struct cor row[1004];
	int l[1004][1004];
	for(i=0;i<n;i++)
		col[i].real=i;
	for(i=0;i<m;i++)
		row[i].real=i;
	for(i=0;i<m;i++)
		for(j=0;j<n;j++){
			getword(s,20);
			l[i][j]=atoi(s);
		}
	for(i=0;i<q;i++){
		c=getchar();
		getchar();
		e=getchar()-'0'-1;
		getchar();
		w=getchar()-'0'-1;
		getchar();
		if(c=='c'){
			temp=col[w].real;
			col[w].real=col[e].real;
			col[e].real=temp;
		}else if(c=='r'){
			temp=row[w].real;
			row[w].real=row[e].real;
			row[e].real=temp;
		}else if(c=='g'){
			printf("%d\n",l[row[e].real][col[w].real]);
		}
	}
	return 0;
}


/*
ID: mohamma73
LANG: C
TASK: crypt1
*/

#include"stdio.h"
#include"stdlib.h"
#include"ctype.h"
#include"math.h"
#include"string.h"
struct cor{
	int real;
	int indx;
};
struct card{
	int val;
	char suit;
	int id;
};
struct point{
	int x;
	int y;
	int visit;
};
struct node{
	int id;
	int n;
	int nei[102];
};
struct person{
	int id;
	int nd;
	int nl;
	int like[2004];
	int dis[2004];
	int visit;
};
struct farmer{
	int p;
	int c;
};
void inc(int *a,int n){
	int i;
	if(a[0]!=2){
		a[0]++;
		return;
	}
	for(i=0;i<n && a[i]==2;i++)
		a[i]=0;
	if(i<n)
		a[i]++;
}
int cmp(char *s,char *t){
	int n=strlen(s);
	int m=strlen(t);
	int i,j;
	for(i=0,j=0;i<n && j<m && s[i]==t[j];i++,j++);
	if(s[i]>t[j])
		return 1;
	else if(s[i]<t[j])
		return -1;
	else
		return 0;

}
int getword(char *s,int n){
	int i;
	char c;
	while(isspace(c=getchar()));
	for(i=0;i<n && !isspace(c);i++,c=getchar())
		s[i]=c;
	s[i++]='\0';
	return i-1;
}
int fgetword(char *s,int n,FILE *fp){
	int i;
	char c;
	while(isspace(c=getc(fp)));
	for(i=0;i<n && !isspace(c) && c!=EOF;i++,c=getc(fp))
		s[i]=c;
	s[i++]='\0';
	return i-1;
}
long long atll(char *s){
	long long n=0;
	int i;
	for(i=0;s[i]!='\0';i++){
		n*=10;
		n+=(s[i]-'0');
	}
	return n;
}
int Bsear(char *s,char words[][13],int n){
	int l=0;
	int h=n;
	int mid;
	while(l<h){
		mid=(l+h)/2;
		if(cmp(words[mid],s)==0)
			return 1;
		else if(cmp(words[mid],s)==1){
			h=mid;
		}else
			l=mid+1;
	}
	return -1;
}
void func(int *n,int base,int num){
	int i=0;
	while(num/base!=0){
		n[i++]=num%base;
		num/=base;
	}
	n[i++]=num;
	n[i++]=20;
}
int pal(int *n){
	int i,j;
	for(i=0;n[i]!=20;i++);
	for(j=0;j<i/2 && n[j]==n[i-j-1];j++);
	if(j==i/2)
		return 1;
	return 0;
}
int ispal(char *s, int i, int j){
	int k;
	for(k=0;k<((j-i+1)/2) && s[i+k]==s[j-k];k++);
	if(k==(j-i+1)/2)
		return 1;
	return 0;
}
void insort(int *a,int n){
	int i,j,temp;
	for(i=1;i<n;i++){
		j=i;
		while(j>0 && a[j]<a[j-1]){
			temp=a[j-1];
			a[j-1]=a[j];
			a[j]=temp;
			j--;
		}
	}
}
char lower(char c){
	return c<'a'?c+('a'-'A'):c;
}
void sort(int *a,int n){
	int i,j,temp;
	for(i=1;i<n;i++)
		for(j=i;j>0 && a[j-1]>a[j];j--){
				temp=a[j];
				a[j]=a[j-1];
				a[j-1]=temp;

		}
}
void fun(int n,char *s){
	int i=0;
	for(i=0;n/10!=0;i++,n/=10)
		s[i]=n%10+'0';
	s[i++]=n+'0';
	s[i]='\0';
}
void sortIn(int *a,int *indx,int n){
	int t1;
	int i,j;
	for(i=1;i<n;i++)
		for(j=i;j>0 && a[j-1]>a[j];j--){
			t1=a[j-1];
			a[j-1]=a[j];
			a[j]=t1;
			t1=indx[j-1];
			indx[j-1]=indx[j];
			indx[j]=t1;
		}
}
int valid(int *a,int l,int r,int n){
	int f=0;
	if(l>0 && a[l-1]>a[r])
		f=1;
	if(a[l+1]<a[r])
		f=1;
	if(a[r-1]>a[l])
		f=1;
	if(r<n-1 && a[r+1]<a[l])
		f=1;
	if(f)
		return 0;
	return 1;
}
void change(char *stripe,int *colors,int idx,int k){
	int j=0;
	if(idx==1){
		if(stripe[0]-'A'>0)
			stripe[0]=colors[stripe[0]-'A'-1];
		else
			stripe[0]=colors[stripe[0]-'A'+1];
		return ;
	}
	for(j=0;j<idx;j+=2){
		if(stripe[j]-'A'>0){
			if(stripe[j]==stripe[j+1])
				stripe[j]=colors[stripe[j]-'A'-1];
			else if(stripe[j+1]!=colors[stripe[j]-'A'-1])
				stripe[j]=colors[stripe[j]-'A'-1];
			else if(stripe[j]-'A'<k-1)
				stripe[j]=colors[stripe[j]-'A'+1];
			else
				stripe[j]=colors[stripe[j]-'A'-2];
		}else{
			if(stripe[j]==stripe[j+1])
				stripe[j]=colors[stripe[j]-'A'+1];
			else
				stripe[j]=colors[stripe[j]-'A'+2];
		}
	}
}
int invite(struct point *nom[],int n,struct point *pts[],int m,struct point *invite[]){
	int i,j,idx=0;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			if(nom[i]->x==pts[j]->x || nom[i]->y==pts[j]->y){
				if(pts[j]->visit==0){
					invite[idx++]=pts[j];
					pts[j]->visit=1;
				}
			}
		}

	}
	return idx;
}
int feasible(struct person *a[],int n){
	int i,j,k;
	int flag=1;
	for(i=0;flag && i<n;i++)
		for(j=0;flag && j<a[i]->nd;j++)
			for(k=0;flag &&k<n;k++){
				if(a[k]->id==a[i]->dis[j]){
					flag=0;
					break;
				}
			}
	if(i==n)
		return 1;
	return 0;
}
int find(struct node *p,struct node *node[]){
	int i,j,k;
	int count=0;
	for(i=0;i<p->n;i++){
		if(p->nei[i]==-1)
			continue;
		for(j=0;j<node[p->nei[i]]->n;j++){
			if(node[p->nei[i]]->nei[j]==-1)
				continue;
			for(k=0;k<p->n;k++){
				if(p->nei[k]==-1)
					continue;
				if(node[p->nei[i]]->nei[j]==p->nei[k])
					count++;
			}
		}
	}

	return count;
}
void rem(struct node *p,struct node *nodes[],int n){
	int i,j;
	for(i=0;i<n;i++){
		if(nodes[i]==NULL)
			continue;
		for(j=0;j<nodes[i]->n;j++)
			if(nodes[i]->nei[j]==p->id)
				nodes[i]->nei[j]=-1;
	}
}
/*int a[55][55][55][55];
int dfs(struct card piles[],int n){
	if(n==1)
		return a[n][piles[0].id][0][0]=1;
	if(n==2)
		if(a[n][piles[n-1].id][piles[n-2].id][0]!=-1){
			//printf("HMM");
			return a[n][piles[n-1].id][piles[n-2].id][0];
		}
	if(n>2){
		if(a[n][piles[n-1].id][piles[n-2].id][piles[n-3].id]!=-1){
			return a[n][piles[n-1].id][piles[n-2].id][piles[n-3].id];
		}
	}
	if(n>1){
		if(piles[n-1].val==piles[n-2].val || piles[n-1].suit==piles[n-2].suit){
			struct card p[n-1];
			int i;
			for(i=0;i<n-1;i++){
				p[i].suit=piles[i].suit;
				p[i].val=piles[i].val;
				p[i].id=piles[i].id;
			}
			p[n-2].val=piles[n-1].val;
			p[n-2].suit=piles[n-1].suit;
			p[n-2].id=piles[n-1].id;
			if(n==2)
				return a[n][piles[n-1].id][piles[n-2].id][0]=1;
			if(dfs(p,n-1))
				return a[n][piles[n-1].id][piles[n-2].id][piles[n-3].id]=1;
		}else if(n==2)
			return a[n][piles[n-1].id][piles[n-2].id][0]=0;
	}
	if(n>3){
		if(a[n][piles[n-1].id][piles[n-2].id][piles[n-3].id]!=-1)
			return a[n][piles[n-1].id][piles[n-2].id][piles[n-3].id];
		if(piles[n-1].suit==piles[n-4].suit || piles[n-1].val==piles[n-4].val){
				struct card p[n];
				int i;
				for(i=0;i<n;i++){
					p[i].suit=piles[i].suit;
					p[i].val=piles[i].val;
					p[i].id=piles[i].id;
				}
				p[n-4].suit=p[n-1].suit;
				p[n-4].val=p[n-1].val;
				p[n-4].id=p[n-1].id;
				if(dfs(p,n-1))
					return a[n][piles[n-1].id][piles[n-2].id][piles[n-3].id]=1;
			}
	}
	return a[n][piles[n-1].id][piles[n-2].id][piles[n-3].id]=0;
}*/
main(){
	char s[20];
	int e,i,j,temp;
	int w;
	char c;
	getword(s,20);
	int m=atoi(s);
	getword(s,20);
	int n=atoi(s);
	getword(s,20);
	int q=atoi(s);
	struct cor col[n];
	struct cor row[m];
	int l[m][n];
	for(i=0;i<n;i++){
		col[i].indx=i;
		col[i].real=i;
	}
	for(i=0;i<m;i++){
		row[i].indx=i;
		row[i].real=i;
	}
	for(i=0;i<m;i++)
		for(j=0;j<n;j++){
			getword(s,20);
			l[i][j]=atoi(s);
		}
	for(i=0;i<q;i++){
		c=getchar();
		getchar();
		e=getchar()-'0'-1;
		getchar();
		w=getchar()-'0'-1;
		getchar();
		if(c=='c'){
			temp=col[w].real;
			col[w].real=col[e].real;
			col[e].real=temp;
		}else if(c=='r'){
			temp=row[w].real;
			row[w].real=row[e].real;
			row[e].real=temp;
		}else if(c=='g'){
			printf("%d\n",l[row[e].real][col[w].real]);
		}
	}
	return 0;
}


/*
ID: mohamma73
LANG: C
TASK: crypt1
*/

#include"stdio.h"
#include"stdlib.h"
#include"ctype.h"
#include"math.h"
#include"string.h"
struct cor{
	int real;
	int indx;
};
struct card{
	int val;
	char suit;
	int id;
};
struct point{
	int x;
	int y;
	int visit;
};
struct node{
	int id;
	int n;
	int nei[102];
};
struct person{
	int id;
	int nd;
	int nl;
	int like[2004];
	int dis[2004];
	int visit;
};
struct farmer{
	int p;
	int c;
};
void inc(int *a,int n){
	int i;
	if(a[0]!=2){
		a[0]++;
		return;
	}
	for(i=0;i<n && a[i]==2;i++)
		a[i]=0;
	if(i<n)
		a[i]++;
}
int cmp(char *s,char *t){
	int n=strlen(s);
	int m=strlen(t);
	int i,j;
	for(i=0,j=0;i<n && j<m && s[i]==t[j];i++,j++);
	if(s[i]>t[j])
		return 1;
	else if(s[i]<t[j])
		return -1;
	else
		return 0;

}
int getword(char *s,int n){
	int i;
	char c;
	while(isspace(c=getchar()));
	for(i=0;i<n && !isspace(c);i++,c=getchar())
		s[i]=c;
	s[i++]='\0';
	return i-1;
}
int fgetword(char *s,int n,FILE *fp){
	int i;
	char c;
	while(isspace(c=getc(fp)));
	for(i=0;i<n && !isspace(c) && c!=EOF;i++,c=getc(fp))
		s[i]=c;
	s[i++]='\0';
	return i-1;
}
long long atll(char *s){
	long long n=0;
	int i;
	for(i=0;s[i]!='\0';i++){
		n*=10;
		n+=(s[i]-'0');
	}
	return n;
}
int Bsear(char *s,char words[][13],int n){
	int l=0;
	int h=n;
	int mid;
	while(l<h){
		mid=(l+h)/2;
		if(cmp(words[mid],s)==0)
			return 1;
		else if(cmp(words[mid],s)==1){
			h=mid;
		}else
			l=mid+1;
	}
	return -1;
}
void func(int *n,int base,int num){
	int i=0;
	while(num/base!=0){
		n[i++]=num%base;
		num/=base;
	}
	n[i++]=num;
	n[i++]=20;
}
int pal(int *n){
	int i,j;
	for(i=0;n[i]!=20;i++);
	for(j=0;j<i/2 && n[j]==n[i-j-1];j++);
	if(j==i/2)
		return 1;
	return 0;
}
int ispal(char *s, int i, int j){
	int k;
	for(k=0;k<((j-i+1)/2) && s[i+k]==s[j-k];k++);
	if(k==(j-i+1)/2)
		return 1;
	return 0;
}
void insort(int *a,int n){
	int i,j,temp;
	for(i=1;i<n;i++){
		j=i;
		while(j>0 && a[j]<a[j-1]){
			temp=a[j-1];
			a[j-1]=a[j];
			a[j]=temp;
			j--;
		}
	}
}
char lower(char c){
	return c<'a'?c+('a'-'A'):c;
}
void sort(int *a,int n){
	int i,j,temp;
	for(i=1;i<n;i++)
		for(j=i;j>0 && a[j-1]>a[j];j--){
				temp=a[j];
				a[j]=a[j-1];
				a[j-1]=temp;

		}
}
void fun(int n,char *s){
	int i=0;
	for(i=0;n/10!=0;i++,n/=10)
		s[i]=n%10+'0';
	s[i++]=n+'0';
	s[i]='\0';
}
void sortIn(int *a,int *indx,int n){
	int t1;
	int i,j;
	for(i=1;i<n;i++)
		for(j=i;j>0 && a[j-1]>a[j];j--){
			t1=a[j-1];
			a[j-1]=a[j];
			a[j]=t1;
			t1=indx[j-1];
			indx[j-1]=indx[j];
			indx[j]=t1;
		}
}
int valid(int *a,int l,int r,int n){
	int f=0;
	if(l>0 && a[l-1]>a[r])
		f=1;
	if(a[l+1]<a[r])
		f=1;
	if(a[r-1]>a[l])
		f=1;
	if(r<n-1 && a[r+1]<a[l])
		f=1;
	if(f)
		return 0;
	return 1;
}
void change(char *stripe,int *colors,int idx,int k){
	int j=0;
	if(idx==1){
		if(stripe[0]-'A'>0)
			stripe[0]=colors[stripe[0]-'A'-1];
		else
			stripe[0]=colors[stripe[0]-'A'+1];
		return ;
	}
	for(j=0;j<idx;j+=2){
		if(stripe[j]-'A'>0){
			if(stripe[j]==stripe[j+1])
				stripe[j]=colors[stripe[j]-'A'-1];
			else if(stripe[j+1]!=colors[stripe[j]-'A'-1])
				stripe[j]=colors[stripe[j]-'A'-1];
			else if(stripe[j]-'A'<k-1)
				stripe[j]=colors[stripe[j]-'A'+1];
			else
				stripe[j]=colors[stripe[j]-'A'-2];
		}else{
			if(stripe[j]==stripe[j+1])
				stripe[j]=colors[stripe[j]-'A'+1];
			else
				stripe[j]=colors[stripe[j]-'A'+2];
		}
	}
}
int invite(struct point *nom[],int n,struct point *pts[],int m,struct point *invite[]){
	int i,j,idx=0;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			if(nom[i]->x==pts[j]->x || nom[i]->y==pts[j]->y){
				if(pts[j]->visit==0){
					invite[idx++]=pts[j];
					pts[j]->visit=1;
				}
			}
		}

	}
	return idx;
}
int feasible(struct person *a[],int n){
	int i,j,k;
	int flag=1;
	for(i=0;flag && i<n;i++)
		for(j=0;flag && j<a[i]->nd;j++)
			for(k=0;flag &&k<n;k++){
				if(a[k]->id==a[i]->dis[j]){
					flag=0;
					break;
				}
			}
	if(i==n)
		return 1;
	return 0;
}
int find(struct node *p,struct node *node[]){
	int i,j,k;
	int count=0;
	for(i=0;i<p->n;i++){
		if(p->nei[i]==-1)
			continue;
		for(j=0;j<node[p->nei[i]]->n;j++){
			if(node[p->nei[i]]->nei[j]==-1)
				continue;
			for(k=0;k<p->n;k++){
				if(p->nei[k]==-1)
					continue;
				if(node[p->nei[i]]->nei[j]==p->nei[k])
					count++;
			}
		}
	}

	return count;
}
void rem(struct node *p,struct node *nodes[],int n){
	int i,j;
	for(i=0;i<n;i++){
		if(nodes[i]==NULL)
			continue;
		for(j=0;j<nodes[i]->n;j++)
			if(nodes[i]->nei[j]==p->id)
				nodes[i]->nei[j]=-1;
	}
}
main(){
	char s[20];
	int e,i,j,temp;
	int w;
	char c;
	getword(s,20);
	int m=atoi(s);
	getword(s,20);
	int n=atoi(s);
	getword(s,20);
	int q=atoi(s);
	struct cor col[n];
	struct cor row[m];
	int l[m][n];
	for(i=0;i<n;i++)
		col[i].real=i;
	for(i=0;i<m;i++)
		row[i].real=i;
	for(i=0;i<m;i++)
		for(j=0;j<n;j++){
			getword(s,20);
			l[i][j]=atoi(s);
		}
	for(i=0;i<q;i++){
		c=getchar();
		getchar();
		getword(s,20);
		e=atoi(s)-1;
		getword(s,20);
		w=atoi(s)-1;
		if(c=='c'){
			temp=col[w].real;
			col[w].real=col[e].real;
			col[e].real=temp;
		}else if(c=='r'){
			temp=row[w].real;
			row[w].real=row[e].real;
			row[e].real=temp;
		}else if(c=='g'){
			printf("%d\n",l[row[e].real][col[w].real]);
		}
	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#define MaxN 1000
int a[MaxN+1][MaxN+1];
int origr[MaxN+1],origc[MaxN+1];

void swap(int *a, int *b)
{
    int t = *a;
    *a = *b;
    *b = t;
}
int main()
{
    int i,j;
    int n,m,q;
    int x,y;
    char c;
    scanf("%d %d %d",&n,&m,&q);
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            scanf("%d",a[i][j]);
        }
    }
    for(i=0;i<n;i++)
    {
        origc[i]=i;
        origr[i]=i;
    }
    for(i=0;i<q;i++)
    {
        scanf("%c %d %d",&c,&x,&y);
        {
            if(c=='c')
            {
                swap(&origc[x],&origc[y]);
            }
            if(c=='r')
            {
                swap(&origr[x],&origr[y]);
            }
            if(c=='q')
            {
                printf("%d",a[origc[x],origr[y]]);
            }
        }
    }
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#define MaxN 1000
int a[MaxN+1][MaxN+1];
int origr[MaxN+1],origc[MaxN+1];

void swap(int *a, int *b)
{
    int t = *a;
    *a = *b;
    *b = t;
}
int main()
{
    int i,j;
    int n,m,q;
    int x,y;
    char c;
    scanf("%d %d %d",&n,&m,&q);
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            scanf("%d",a[i][j]);
        }
    }
    for(i=0;i<n;i++)
    {
        origc[i]=i;
        origr[i]=i;
    }
    for(i=0;i<q;i++)
    {
        scanf("%c %d %d",&c,&x,&y);
        {
            if(c=='c')
            {
                swap(&origc[x],&origc[y]);
            }
            if(c=='r')
            {
                swap(&origr[x],&origr[y]);
            }
            if(c=='q')
            {
                printf("%d",a[origc[x],origr[y]]);
            }
        }
    }
    system("pause");
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#define MaxN 1000
int a[MaxN+1][MaxN+1];
int origr[MaxN+1],origc[MaxN+1];

void swap(int *a, int *b)
{
    int t = *a;
    *a = *b;
    *b = t;
}
int main()
{
    int i,j;
    int n,m,k;
    int x,y;
    char c;
    scanf("%d %d %d",&n,&m,&k);
    for(i=1;i<=n;i++)
        for(j=1;j<=m;j++)
            scanf("%d",&a[i][j]);
    for(i=1;i<=n;i++)
        origr[i]=i;
    for (i = 1; i <= m; i++)
        origc[i]=i;
    for(i=0;i<k;i++)
    {
        do
            c = getchar();
        while (c != 'c' && c != 'r' && c != 'g');

        scanf("%d %d",&x,&y);

        if(c=='c')
            swap(&origc[x],&origc[y]);
        else if(c=='r')
            swap(&origr[x],&origr[y]);
        else if(c=='g')
            printf("%d\n",a[origr[x]][origc[y]]);
    }
    return 0;
}


#include<stdio.h>
int arr[50][50],n,m;
int swaprow(int x,int y)
{
    int i,j,t;
    for(i=0;i<m;i++)
    {
        t=arr[x][i];
        arr[x][i]=arr[y][i];
        arr[y][i]=t;
    }
}
int swapcol(int x,int y)
{
    int t,i,j;
    for(i=0;i<n;i++)
    {
        t=arr[i][x];
        arr[i][x]=arr[i][y];
        arr[i][y]=t;
    }
}
int main()
{
    int i,j,k,x,y;
    char q;
    scanf("%d %d %d",&n,&m,&k);
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            scanf("%d",&arr[i][j]);
        }
    }
    for(i=0;i<k;i++)
    {
        scanf("%c %d %d",&q,&x,&y);
        if(q=='r')
        {
            swaprow(x-1,y);
        }
        else if(q=='c')
        {
            swapcol(x,y-1);
        }
        else
        printf("%d\n",arr[x-1][y-1]);
    }
    return 0;
}


#include<stdio.h>

int arr[1010][1010],n,m;

int swapcolumn(int a,int b)
{
    int i,j,temp;
    for(i=0;i<n;i++)
    {
        temp=arr[i][a];
        arr[i][a]=arr[i][b];
        arr[i][b]=temp;
    }
}

int swaprow(int a,int b)
{
    int i,j,temp;
    for(i=0;i<m;i++)
    {
        temp=arr[a][i];
        arr[a][i]=arr[b][i];
        arr[b][i]=temp;
    }
}

int main()
{
    int k,i,j,row,col;
    char ch;
    scanf("%d%d%d",&n,&m,&k);
    for(i=0;i<n;i++)
    for(j=0;j<m;j++)
    scanf("%d",&arr[i][j]);

    for(i=0;i<k;i++)
    {
        scanf(" %c %d %d",&ch,&row,&col);

        if(ch=='c')
        {
            swapcolumn(row-1,col-1);
        }
        else if(ch=='r')
        swaprow(row-1,col-1);
        else
        printf("%d\n",arr[row-1][col-1]);
    }
    return(0);

}


#include <stdio.h>
int main(){
    int n,m,k,i,j,array[1000][1000],row[1000],column[1000],x,y,temp,a=0;
    char op;
    scanf("%d %d %d",&n,&m,&k);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&array[i][j]);
        }
    }
    for(i=0;i<n;i++){
        row[i]=i;
    }
    for(i=0;i<m;i++){
        column[i]=i;
    }
    for(j=0;j<k*2;j++){
        scanf("%c",&op);
        scanf("%d %d",&x,&y);

        if(op=='c'){
            //printf("c");
            temp=column[x-1];
            column[x-1]=column[y-1];
            column[y-1]=temp;
        }
        else if(op=='r'){
            //printf("r");
            temp=row[x-1];
            row[x-1]=row[y-1];
            row[y-1]=temp;
        }
        if(op=='g'){
            //printf("g");
            printf("%d\n",array[row[x-1]][column[y-1]]);

        }
    }
    return 0;
}


#include<stdio.h>

int arr[1010][1010],n,m,k;

int swapcolumn(int a,int b)
{
    int i,j,temp;
    for(i=0;i<n;i++)
    {
        temp=arr[i][a];
        arr[i][a]=arr[i][b];
        arr[i][b]=temp;
    }
}

int swaprow(int a,int b)
{
    int i,j,temp;
    for(i=0;i<m;i++)
    {
        temp=arr[a][i];
        arr[a][i]=arr[b][i];
        arr[b][i]=temp;
    }
}

int main()
{
    int i,j,row,col;
    char ch;
    scanf("%d%d%d",&n,&m,&k);
    for(i=0;i<n;i++)
    for(j=0;j<m;j++)
    scanf("%d",&arr[i][j]);

    for(i=0;i<k;i++)
    {
        scanf(" %c %d %d",&ch,&row,&col);

        if(ch=='c')
        {
            swapcolumn(row-1,col-1);
        }
        else if(ch=='r')
        swaprow(row-1,col-1);
        else
        printf("%d\n",arr[row-1][col-1]);
    }
    return(0);

}


#include<stdio.h>

int arr[101][101],n,m;

int swapcolumn(int a,int b)
{
    int i,j,temp;
    for(i=0;i<n;i++)
    {
        temp=arr[i][a];
        arr[i][a]=arr[i][b];
        arr[i][b]=temp;
    }
}

int swaprow(int a,int b)
{
    int i,j,temp;
    for(i=0;i<m;i++)
    {
        temp=arr[a][i];
        arr[a][i]=arr[b][i];
        arr[b][i]=temp;
    }
}

int main()
{
    int i,j,row,col,k;
    char ch;
    scanf("%d%d%d",&n,&m,&k);
    for(i=0;i<n;i++)
    for(j=0;j<m;j++)
    scanf("%d",&arr[i][j]);

    for(i=0;i<k;i++)
    {
        scanf(" %c %d %d",&ch,&row,&col);

        if(ch=='c')
        {
            swapcolumn(row-1,col-1);
        }
        else if(ch=='r')
        swaprow(row-1,col-1);
        else
        printf("%d\n",arr[row-1][col-1]);
    }
    return(0);

}


#include <stdio.h>

int table[1001][1001];

int main(int argc, char *argv[])
{
	int n, m, k, i, j, x, y;
	char c;

	scanf("%d %d %d", &n, &m, &k);
	for(i = 1; i <= n; i ++)
		for(j = 1; j <= m; j ++)
			scanf("%d", &table[i][j]);

	while(k --)
	{
		scanf(" %c %d %d", &c, &x, &y);
		if(c == 'g')
			printf("%d\n", table[x][y]);
		else if(c == 'r')
			for(j = 1; j <= m; j ++)
			{
				i = table[x][j];
				table[x][j] = table[y][j];
				table[y][j] = i;
			}
		else if(c == 'c')
		{
			for(i = 1; i <= n; i ++)
			{
				j = table[i][x];
				table[i][x] = table[i][y];
				table[i][y] = j;
			}
		}
	}

	return 0;
}


#include <stdio.h>

int table[1001][1001], row[1001], col[1001];

int main(int argc, char *argv[])
{
	int n, m, k, i, j, x, y;
	char c;

	scanf("%d %d %d", &n, &m, &k);
	for(i = 1; i <= n; i ++)
		for(j = 1; j <= m; j ++)
			scanf("%d", &table[i][j]);

	for(i = 1; i <= n; i ++)
		row[i] = i;
	for(j = 1; j <= m; j ++)
		col[j] = j;

	while(k --)
	{
		scanf(" %c %d %d", &c, &x, &y);
		if(c == 'g')
			printf("%d\n", table[row[x]][col[y]]);
		else if(c == 'r' && x != y)
		{
			row[x] ^= row[y];
			row[y] ^= row[x];
			row[x] ^= row[y];
		}
		else if(c == 'c' && x != y)
		{
			col[x] ^= col[y];
			col[y] ^= col[x];
			col[x] ^= col[y];
		}
	}

	return 0;
}


#include<stdio.h>
int invmapr[1005],invmapc[1005];
int orig[1005][1005];
int main()
{
	int col, row, que, i, j;
	scanf("%d%d%d", &row, &col, &que);
	for(i=1;i<=row;i++)
	{
		invmapr[i] = i;
		for(j=1;j<=col;j++)
		{
			scanf("%d",&orig[i][j]);
			invmapc[j] = j;
		}
	}
	char query[10];
	int xi, yi;
	int temp;
	for (i = 0; i < que; i++) {
		scanf("%s%d%d", query, &xi, &yi);
		switch(query[0]) {
			case 'c':
				temp = invmapc[xi];
				invmapc[xi] = invmapc[yi];
				invmapc[yi] = temp;
				break;
			case 'r':
				temp = invmapr[xi];
				invmapr[xi] = invmapr[yi];
				invmapr[yi] = temp;
				break;
			case 'g':
				printf("%d\n", orig[invmapr[xi]][invmapc[yi]]);

				break;
		}
	}
	return 0;

}


#include<stdio.h>

int main() {

    int c, r, k;

    int i,j;

    int row[1001];
    int col[1001];
    int a[1001][1001];

    scanf("%d%d%d", &r, &c, &k);

    for ( i = 1; i <= r; i++ ) {

	for ( j = 1; j <= c; j++ ) {

		scanf("%d", &a[i][j]);

	}

    }

    for( i = 1; i <= r; i++ ) row[i] = i;
    for( i = 1; i <= c; i++ ) col[i] = i;

    int l;

    char p[2];

    int t, y;

    for ( l = 1; l <= k; l++ ) {

	scanf("%s", p);

	scanf("%d %d", &t, &y);

	if( p[0] == 'r' ) {

	    row[t] = y;
	    row[y] = t;

	}

	else if ( p[0] == 'c' ) {

	    col[t] = y;
	    col[y] = t;

	}
	else {

	    int temp = row[t];
	    int tt = col[y];
	    printf("%d\n",a[temp][tt]);

	}

    }

    return 0;

}


#include<stdio.h>

int main() {

    int c, r, k;

    int i,j;

    int row[1001];
    int col[1001];
    int a[1001][1001];

    scanf("%d%d%d", &r, &c, &k);

    for ( i = 1; i <= r; i++ ) {

	for ( j = 1; j <= c; j++ ) {

		scanf("%d", &a[i][j]);

	}

    }

    for( i = 1; i <= r; i++ ) row[i] = i;
    for( i = 1; i <= c; i++ ) col[i] = i;

    int l;

    char p[2];

    int t, y;

    for ( l = 1; l <= k; l++ ) {

	scanf("%s", p);

	scanf("%d %d", &t, &y);

	if( p[0] == 'r' ) {

	    int temp = row[t];
	    row[t] = row[y];
	    row[y] = temp;

	}

	else if ( p[0] == 'c' ) {

	    int temp = col[t];
	    col[t] = col[y];
	    col[y] = temp;

	}
	else {

	    int temp = row[t];
	    int tt = col[y];
	    printf("%d\n",a[temp][tt]);

	}

    }

    return 0;

}


#include <stdio.h>
#include <stdlib.h>
#define MAXN 1010

int col[MAXN], row[MAXN];
int a[MAXN][MAXN];
int n, m, k;

void swap(int *a, int *b)
{
    int tmp;
    tmp=*a; *a=*b; *b=tmp;
}

int main()
{
    int i, j;
    char flag;
    scanf("%d%d%d",&n,&m,&k);
    for (i=1;i<=n;i++)
        for (j=1;j<=m;j++)
            scanf("%d",&a[i][j]);
    for (i=1;i<=n;i++) row[i]=i;
    for (i=1;i<=m;i++) col[i]=i;
    while (k)
    {
        scanf("%c",&flag);

        scanf("%c%d%d",&flag, &i, &j);
        if (flag=='r') swap(&row[i],&row[j]);
        else
            if (flag=='c') swap(&col[i],&col[j]);
            else printf("%d\n",a[row[i]][col[j]]);
        k--;
    }
    return 0;
}


#include<stdio.h>

int main()
{
	int table[1001][1001];
	int row[1001], col[1001];
	int n, m, k, i, j;
	char op;
	int op1, op2;
	int temp;
	scanf("%d %d %d", &n, &m, &k);
	for (i = 0; i < n; i++)
		row[i] = i;
	for (i = 0; i < m; i++)
		col[i] = i;
	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++)
			scanf("%d", &table[i][j]);
	for (i = 0; i<k; i++)
	{
		getchar();
		scanf("%c %d %d", &op, &op1, &op2);
		op1--;
		op2--;
		if (op == 'c')
		{
			temp = col[op1];
			col[op1] = col[op2];
			col[op2] = temp;
		}
		else if (op == 'r')
		{
			temp = row[op1];
			row[op1] = row[op2];
			row[op2] = temp;
		}
		else if (op == 'g')
			printf("%d\n", table[row[op1]][col[op2]]);
	}
	return 0;
}


#include<stdio.h>

#define MAX_COL 1000
#define MAX_ROW 1000

int table[MAX_COL+1][MAX_ROW+1];
int col[MAX_COL+1], row[MAX_ROW+1];

int main()
{
	int n, m, k, i, j, temp;//n is col, m is row
	char op;
	int op1, op2;
	scanf("%d%d%d",&n,&m,&k);
	for (i = 1; i <= n; i++)
		row[i] = i;
	for (i = 1; i <= m; i++)
		col[i] = i;
	for (i = 1; i <= n; i++)
		for (j = 1; j <= m; j++)
			scanf("%d",&table[i][j]);
	for (i = 0; i < k; i++) {
		scanf("%c%d%d",&op,&op1,&op2);
		if (op == 'c') {
			temp = col[op1];
			col[op1] = col[op2];
			col[op2] = temp;
		}
		else if (op == 'r') {
			temp = row[op1];
			row[op1] = row[op2];
			row[op2] = temp;
		}
		else if (op == 'g')
			printf("%d\n",table[row[op1]][col[op2]]);
	}
	return 0;
}


#include<stdio.h>

int main()
{
	int table[1001][1001];
	int row[1001], col[1001];
	int n, m, k, i, j;
	char op;
	int op1, op2;
	int temp;
	scanf("%d %d %d", &n, &m, &k);
	for (i = 0; i<1001; i++)
	{
		row[i] = i;
		col[i] = i;
	}
	for (i = 0; i<n; i++)
		for (j = 0; j<m; j++)
			scanf("%d", &table[i][j]);
	for (i = 0; i<k; i++)
	{
		getchar();
		scanf("%c %d %d", &op, &op1, &op2);
		op1--;
		op2--;
		if (op == 'g')
			printf("%d\n", table[row[op1]][col[op2]]);
		else if (op == 'c')
		{
			temp = col[op1];
			col[op1] = col[op2];
			col[op2] = temp;
		}
		else if (op == 'r')
		{
			temp = row[op1];
			row[op1] = row[op2];
			row[op2] = temp;
		}
	}
	return 0;
}


#include<iostream>
using namespace std;

#define MAX_COL 1000
#define MAX_ROW 1000

int table[MAX_COL+1][MAX_ROW+1];
int col[MAX_COL+1], row[MAX_ROW+1];

int main()
{
	int n, m, k, i, j, temp;//n is col, m is row
	char op;
	int op1, op2;
	scanf("%d %d %d", &n, &m, &k);
//	cin >> n >> m >> k;
	for (i = 1; i <= n; i++)
		row[i] = i;
	for (i = 1; i <= m; i++)
		col[i] = i;
	for (i = 1; i <= n; i++)
		for (j = 1; j <= m; j++)
			scanf("%d", &table[i][j]);
//			cin >> table[i][j];
	for (i = 0; i < k; i++) {
		scanf("%c %d %d", &op, &op1, &op2);
//		cin >> op >> op1 >> op2;
		if (op == 'c') {
			temp = col[op1];
			col[op1] = col[op2];
			col[op2] = temp;
		}
		else if (op == 'r') {
			temp = row[op1];
			row[op1] = row[op2];
			row[op2] = temp;
		}
		else if (op == 'g')
			printf("%d\n", table[row[op1]][col[op2]]);
//			cout << table[row[op1]][col[op2]] << endl;
	}
	return 0;
}


#include<stdio.h>

#define MAX_COL 1000
#define MAX_ROW 1000

int table[MAX_COL+1][MAX_ROW+1];
int col[MAX_COL+1], row[MAX_ROW+1];

int main()
{
	int n, m, k, i, j, temp;//n is col, m is row
	char op;
	int op1, op2;
	scanf("%d %d %d", &n, &m, &k);
//	cin >> n >> m >> k;
	for (i = 1; i <= n; i++)
		row[i] = i;
	for (i = 1; i <= m; i++)
		col[i] = i;
	for (i = 1; i <= n; i++)
		for (j = 1; j <= m; j++)
			scanf("%d", &table[i][j]);
//			cin >> table[i][j];
	for (i = 0; i < k; i++) {
		scanf("%c %d %d", &op, &op1, &op2);
//		cin >> op >> op1 >> op2;
		if (op == 'c') {
			temp = col[op1];
			col[op1] = col[op2];
			col[op2] = temp;
		}
		else if (op == 'r') {
			temp = row[op1];
			row[op1] = row[op2];
			row[op2] = temp;
		}
		else if (op == 'g')
			printf("%d\n", table[row[op1]][col[op2]]);
//			cout << table[row[op1]][col[op2]] << endl;
	}
	return 0;
}


#include<stdio.h>

int main()
{
	int table[1001][1001];
	int row[1001], col[1001];
	int n, m, k, i, j;
	char op;
	int op1, op2;
	int temp;
	scanf("%d %d %d", &n, &m, &k);
	for (i = 1; i <= n; i++)
		row[i] = i;
	for (i = 1; i <= m; i++)
		col[i] = i;
	for (i = 1; i <= n; i++)
		for (j = 1; j <= m; j++)
			scanf("%d", &table[i][j]);
	for (i = 0; i<k; i++)
	{
		getchar();
		scanf("%c %d %d", &op, &op1, &op2);
		if (op == 'c')
		{
			temp = col[op1];
			col[op1] = col[op2];
			col[op2] = temp;
		}
		else if (op == 'r')
		{
			temp = row[op1];
			row[op1] = row[op2];
			row[op2] = temp;
		}
		else if (op == 'g')
			printf("%d\n", table[row[op1]][col[op2]]);
	}
	return 0;
}


#include<stdio.h>

int main()
{
	int table[1001][1001];
	int row[1001], col[1001];
	int n, m, k, i, j;
	char op;
	int op1, op2;
	int temp;
	scanf("%d %d %d", &n, &m, &k);
	for (i = 1; i < n; i++)
		row[i] = i;
	for (i = 0; i < m; i++)
		col[i] = i;
	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++)
			scanf("%d", &table[i][j]);
	for (i = 0; i<k; i++)
	{
		getchar();
		scanf("%c %d %d", &op, &op1, &op2);
		op1--;
		op2--;
		if (op == 'c')
		{
			temp = col[op1];
			col[op1] = col[op2];
			col[op2] = temp;
		}
		else if (op == 'r')
		{
			temp = row[op1];
			row[op1] = row[op2];
			row[op2] = temp;
		}
		else if (op == 'g')
			printf("%d\n", table[row[op1]][col[op2]]);
	}
	return 0;
}


#include<stdio.h>
int arr[1000][1000];
int r[1000];
int c[1000];
int ans[500000];

int main(void){
	//freopen("input.txt","r+",stdin);
	int n,m,k,i,j,q,temp,x,y,rowIndex,colIndex;
	char ch;
	scanf("%d %d %d", &n,&m,&k);
	for(i = 0;i<n;i++){
		for(j = 0;j<m;j++){
			scanf("%d", &arr[i][j]);
		}
		r[i] = i;
	}
	for(j = 0;j<m;j++){
		c[j] = j;
	}

	for(q = 0;q<k;q++){
		scanf(" %c", &ch);
		scanf("%d %d", &x, &y);
		x--;y--;
		if(ch=='r'){
			temp = r[x];
			r[x] = r[y];
			r[y] = temp;
		}else if(ch == 'c'){
			temp = c[x];
			c[x] = c[y];
			c[y] = temp;
		}else if(ch == 'g'){
			rowIndex = r[x];
			colIndex = c[y];
			printf("%d\n", arr[rowIndex][colIndex]);
		}
	}

	return 0;
}


#include <stdio.h>

int a[1001][1001];
int temp;
int n, m, k;

void chng_str (int o, int t){
    int q;
    for (q=1; q<=m; q++){
        temp=a[o][q];
        a[o][q]=a[t][q];
        a[t][q]=temp;
    }
}

void chng_clm (int o, int t){
    int s;
    for (s=1; s<=n; s++){
        temp=a[s][o];
        a[s][o]=a[s][t];
        a[s][t]=temp;
    }
}

int main(){
    int ans[500001];
    int ansc=1;
    int i, j;
    char pf, c;
    int o, t;
    scanf ("%d%d%d", &n, &m, &k);
    for (i=1; i<=n; i++)
        for (j=1; j<=m; j++)
            scanf ("%d", &a[i][j]);
    for (i=1; i<=k; i++){
        scanf ("%c%c%d%d", &pf, &c, &o, &t);
        if (c=='c') chng_str (o, t);
        if (c=='r') chng_clm (o, t);
        if (c=='g') {
            ans[ansc]=a[o][t];
            ansc++;
        }
    }
    for (i=1; i<ansc; i++)
        printf ("%d\n", ans[i]);
    return 0;
}


 #include <stdio.h>

 int n, m, k;
 int p;
 int i, j;
 int q;
 char c, t;
 int x, y;
 int temp;
 int a;

 int tbl[1005][1005];
 int rows[1005];
 int cols[1005];
 int ans [500005];

int main(){
    scanf ("%d%d%d", &n, &m, &k);
    for (i=1; i<=n; i++){
        for (j=1; j<=m; j++){
            scanf ("%d", &p);
            tbl[i][j]=p;
        }
    }
    for (i=1; i<=n; i++)
        rows[i]=i;
    for (j=1; j<=m; j++)
        cols[j]=j;

    a=0;
    for (q=0; q<k; q++){
        scanf ("%c%c%d%d", &t, &c, &x, &y);
        if (c=='r'){
            temp=rows[x];
            rows[x]=rows[y];
            rows[y]=temp;
        }
        if (c=='c'){
            temp=cols[x];
            cols[x]=cols[y];
            cols[y]=temp;
        }
        if (c=='g'){
            ans[a]=tbl[rows[x]][cols[y]];
            a++;
        }
    }
    for (q=0; q<a; q++)
        printf ("%d\n", ans[q]);
    return 0;
}


#include <stdio.h>

int a[1011][1011];
int temp;
int n, m, k;

void chng_str (int o, int t){
    int q;
    for (q=1; q<=m; q++){
        temp=a[o][q];
        a[o][q]=a[t][q];
        a[t][q]=temp;
    }
}

void chng_clm (int o, int t){
    int s;
    for (s=1; s<=n; s++){
        temp=a[s][o];
        a[s][o]=a[s][t];
        a[s][t]=temp;
    }
}

int main(){
    int ans[500010];
    int ansc=1;
    int i, j;
    char pf, c;
    int o, t;
    scanf ("%d%d%d", &n, &m, &k);
    for (i=1; i<=n; i++)
        for (j=1; j<=m; j++)
            scanf ("%d", &a[i][j]);
    for (i=1; i<=k; i++){
        scanf ("%c%c%d%d", &pf, &c, &o, &t);
        if (c=='c') chng_clm (o, t);
        if (c=='r') chng_str (o, t);
        if (c=='g') {
            ans[ansc]=a[o][t];
            ansc++;
        }
    }
    for (i=1; i<ansc; i++)
        printf ("%d\n", ans[i]);
    return 0;
}


#include<stdio.h>
#define Max 1000001
int map[1001][1001];
int change[500001];
int main()
{
    int n,m,i,j,k,q,x,y,t,f=1;
    int line[1001];//��
    int list[1001];//��
    char p;
    scanf("%d %d %d",&n,&m,&k);
    for(i=1;i<=n;i++)
        line[i]=i;
    for(i=1;i<=m;i++)
        list[i]=i;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            scanf("%d",&q);
            map[i][j]=q;
        }
    }

    for(i=1;i<=k;i++)
    {
        scanf("%s %d %d",&p,&x,&y);
        if(p=='r')
        {
            t=line[y];
            line[y]=line[x];
            line[x]=t;
        }
        if(p=='c')
        {
            t=list[y];
            list[y]=list[x];
            list[x]=t;
        }
        if(p=='g')
        {
            change[f]=map[line[x]][list[y]];
            f++;
        }
    }
    for(i=1;i<f;i++)
    {
        printf("%d\n",change[i]);
    }
    getchar();
    getchar();
    return 0;
}


#include<stdio.h>
#define Max 1000000
int map[1000][1000];
int main()
{
    int n,m,i,j,k,q,x,y,t;
    int line[1000];//��
    int list[1000];//��
    char p;
    scanf("%d %d %d",&n,&m,&k);
    for(i=1;i<=n;i++)
        line[i]=i;
    for(i=1;i<=m;i++)
        list[i]=i;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            scanf("%d",&q);
            map[i][j]=q;
        }
    }

    for(i=1;i<=k;i++)
    {
        scanf("%s %d %d",&p,&x,&y);
        if(p=='r')
        {
            t=line[y];
            line[y]=line[x];
            line[x]=t;
        }
        if(p=='c')
        {
            t=list[y];
            list[y]=list[x];
            list[x]=t;
        }
        if(p=='g')
        {
            printf("%d",map[line[x]][list[y]]);
        }
    }

    getchar();
    getchar();
    return 0;
}


#include<stdio.h>
#define Max 1000000
int map[1000][1000];
int change[500001];
int main()
{
    int n,m,i,j,k,q,x,y,t,f=1;
    int line[1000];//��
    int list[1000];//��
    char p;
    scanf("%d %d %d",&n,&m,&k);
    for(i=1;i<=n;i++)
        line[i]=i;
    for(i=1;i<=m;i++)
        list[i]=i;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            scanf("%d",&q);
            map[i][j]=q;
        }
    }

    for(i=1;i<=k;i++)
    {
        scanf("%s %d %d",&p,&x,&y);
        if(p=='r')
        {
            t=line[y];
            line[y]=line[x];
            line[x]=t;
        }
        if(p=='c')
        {
            t=list[y];
            list[y]=list[x];
            list[x]=t;
        }
        if(p=='g')
        {
            change[f]=map[line[x]][list[y]];
            f++;
        }
    }
    for(i=1;i<f;i++)
    {
        printf("%d\n",change[i]);
    }
    getchar();
    getchar();
    return 0;
}


#include<stdio.h>
#define Max 1000001
int map[1001][1001];
int main()
{
    int n,m,i,j,k,q,x,y,t,f=1;
    int line[1001];//��
    int list[1001];//��
    char p;
    scanf("%d %d %d",&n,&m,&k);
    for(i=1;i<=n;i++)
        line[i]=i;
    for(i=1;i<=m;i++)
        list[i]=i;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            scanf("%d",&q);
            map[i][j]=q;
        }
    }

    for(i=1;i<=k;i++)
    {
        scanf("%s %d %d",&p,&x,&y);
        if(p=='r')
        {
            t=line[y];
            line[y]=line[x];
            line[x]=t;
        }
        if(p=='c')
        {
            t=list[y];
            list[y]=list[x];
            list[x]=t;
        }
        if(p=='g')
        {
            printf("%d\n",map[line[x]][list[y]]);
        }
    }
    return 0;
}


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

int ma[1010][1010];
int row[1010], col[1010];

int main()
{
	int i,j,x,y,n,m,k;

	scanf("%d %d %d", &n, &m, &k);
	for (i=1;i<=n;i++)
		for (j=1;j<=m;j++)
			scanf("%d", &ma[i][j]);

	for (i=1;i<=n;i++) row[i] = i;
	for (i=1;i<=m;i++) col[i] = i;

	scanf("\n");

	for (;k;k--)
	{
		char c;
		scanf("%c %d %d\n", &c, &x, &y);

		if (c=='g')
		{
			printf("%d\n", ma[row[x]][col[y]]);
		}
		else if (c=='r')
		{
			int t = row[x];
			row[x] = row[y];
			row[y] = t;
		}
		else
		{
			int t = col[x];
			col[x] = col[y];
			col[y] = t;
		}
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);
    vector<int> a(n);
    for (int& i : a) cin >> i;
    sort(a.begin(), a.end());

    int cnt = 0;
    list<int> lst;
    for (int i = 0; i < n; i++) {
        while (!lst.empty() && lst.front() < a[i] - m + 1)
            lst.pop_front();
        if (lst.size() < k - 1) lst.emplace_back(a[i]);
        else cnt++;
    }
    printf("%d", cnt);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);
    vector<int> a(n);
    for (int& i : a) cin >> i;
    sort(a.begin(), a.end());

    int cnt = 0;
    list<int> lst;
    for (int i = 0; i < n; i++) {
        while (!lst.empty() && lst.front() < a[i] - m + 1)
            lst.pop_front();
        if (lst.size() < k - 1) lst.emplace_back(a[i]);
        else cnt++;
    }
    printf("%d", cnt);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll>pll;
ll bin_pow(ll a,ll b){
    if(b==0)return 1;
    if(b%2==0){
        ll t=bin_pow(a,b/2);
        return t*t%MOD;
    }
    else return a*bin_pow(a,b-1)%MOD;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,m,k,x=0,z,s=0,l,r,t=0;
    cin>>n>>m>>k;
    vector<ll>a(n),b(1000001);
    for(int i=0;i<n;i++)cin>>a[i],b[a[i]]=1;
    for(int i=1;i<=m;i++)s+=b[i];
    r=m;
    while(s>=k){
            if(b[r]==1)t++;
        s-=b[r];
        b[r]=0;
        r--;
    }
    for(int i=m+1;i<=1e6-m+1;i++){
        s+=b[i]-b[i-m];
        r=i;
        while(s>=k){
            if(b[r]==1)t++;
            s-=b[r];
            b[r]=0;
            r--;
        }
    }
    cout<<t;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll>pll;
ll bin_pow(ll a,ll b){
    if(b==0)return 1;
    if(b%2==0){
        ll t=bin_pow(a,b/2);
        return t*t%MOD;
    }
    else return a*bin_pow(a,b-1)%MOD;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,m,k,x=0,z,s=0,l,r,t=0;
    cin>>n>>m>>k;
    vector<ll>a(n),b(1000001);
    for(int i=0;i<n;i++)cin>>a[i],b[a[i]]=1;
    for(int i=1;i<=m;i++)s+=b[i];
    r=m;
    while(s>=k){
            if(b[r]==1)t++;
        s-=b[r];
        b[r]=0;
        r--;
    }
    for(int i=m+1;i<=1e6;i++){
        s+=b[i]-b[i-m];
        r=i;
        while(s>=k){
            if(b[r]==1)t++;
            s-=b[r];
            b[r]=0;
            r--;
        }
    }
    cout<<t;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vs vector<string>
#define vll vector<ll>
#define ii pair<int, int>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define vii vector<ii>
#define vvi vector<vi>
#define vvii vector<vii>
#define ld long double
#define iii tuple<int, int, int>
#define sc scanf
#define pb push_back
#define forn(i, x, n) for(int i=x; i<=n; ++i)
#define rofn(i, x, n) for(int i=x; i>=n; --i)
#define MOD 1000000007
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sze(x) (int) x.size()

int main() {

    int n, m, k;
    sc("%d %d %d", &n, &m, &k);

    vi a(n);

    forn(i, 0, n-1) {
        sc("%d", &a[i]);
    }

    sort(all(a));

    int ans = INT_MAX;

    forn(i, 0, n-1) {

        int in = lower_bound(all(a), a[i] + m) - a.begin();

        ans = min(ans, max(0, (in-i) - (k-1)));

        if(a[n-1] - a[i] <= m-1) break;
    }

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


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vs vector<string>
#define vll vector<ll>
#define ii pair<int, int>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define vii vector<ii>
#define vvi vector<vi>
#define vvii vector<vii>
#define ld long double
#define iii tuple<int, int, int>
#define sc scanf
#define pb push_back
#define forn(i, x, n) for(int i=x; i<=n; ++i)
#define rofn(i, x, n) for(int i=x; i>=n; --i)
#define MOD 1000000007
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sze(x) (int) x.size()

int a[200005], cnt[200005] = {0};

int main() {

    int n, m, k;
    sc("%d %d %d", &n, &m, &k);

    forn(i, 1, n) {
        sc("%d", &a[i]);
    }

    sort(a+1, a+n+1);

    int in = 0, ans = 0;

    for(int i=1; i<=n; ++i) {

        cnt[++in] = a[i];

        if(in >= k && cnt[in] - cnt[in - k + 1] < m) {
            in--;
            ans++;
        }
    }
    printf("%d\n", ans);
}


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

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

	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	set<int> s;
	int ans = 0;
	for(int i = 0; i < n; i++){
		while(!s.empty()){
			if(*s.begin() < a[i] - m + 1)s.erase(s.begin());
			else break;
		}
		if(s.size() < k - 1){
			s.insert(a[i]);
		}else{
			ans++;
		}
	}
	cout << ans << '\n';
}


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

const int N = 1e6 + 5;

int pref[N];

int sum(int l, int r){
	return pref[r - 1] - pref[l - 1];
}
int main(){
	int n, m, k;
	cin >> n >> m >> k;

	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
		pref[a[i]]++;
	}
	sort(a.begin(), a.end());

	for(int i = 1; i <= N - 5; i++){
		pref[i] += pref[i - 1];
	}

	int ans = 0;
	for(int i = 1; i <= N - 5;){
		if(sum(i, i + m) >= k){
			ans += (sum(i, i + m) - k + 1);
			i += m;
		}else{
			i++;
		}
	}
	cout << ans << '\n';
}


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

const int N = 1e7 + 5;

int pref[N];

int sum(int l, int r){
	return pref[r - 1] - pref[l - 1];
}
int main(){
	int n, m, k;
	cin >> n >> m >> k;

	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
		pref[a[i]]++;
	}
	sort(a.begin(), a.end());
	for(int i = 1; i <= N - 5; i++){
		pref[i] += pref[i - 1];
	}

	int ans = 0;

	for(int i = 1; i <= N - 5 - m + 1;){
		if(sum(i, i + m) >= k){
			ans += (sum(i, i + m) - k + 1);
			if(lower_bound(a.begin(), a.end(), i) - a.begin() + (sum(i, i + m) - k + 1) + 1 < n){
				i = a[lower_bound(a.begin(), a.end(), i) - a.begin() + (sum(i, i + m) - k + 1) + 1];
			}else{
				i = a[n - 1] + 1;
			}
		}else{
			i++;
		}
	}
	cout << ans << '\n';
}


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

const int N = 1e7 + 5;

int pref[N];

int sum(int l, int r){
	return pref[r - 1] - pref[l - 1];
}
int main(){
	int n, m, k;
	cin >> n >> m >> k;

	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
		pref[a[i]]++;
	}
	for(int i = 1; i <= N - 5; i++){
		pref[i] += pref[i - 1];
	}

	int ans = 0;

	for(int i = 1; i <= N - 5 - m + 1;){
		if(sum(i, i + m) >= k){
			ans += (sum(i, i + m) - k + 1);
			i += m;
		}else{
			i++;
		}
	}
	cout << ans << '\n';
}


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

const int N = 1e7 + 5;

int pref[N];
bool y[N];

int sum(int l, int r){
	return pref[r - 1] - pref[l - 1];
}
int main(){
	int n, m, k;
	cin >> n >> m >> k;

	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
		pref[a[i]]++;
		y[a[i]] = 1;
	}
	for(int i = 1; i <= N - 5; i++){
		pref[i] += pref[i - 1];
	}

	int ans = 0;

	for(int i = 1; i <= N - 5 - m + 1;){
		if(sum(i, i + m) >= k && y[i]){
			ans += (sum(i, i + m) - k + 1);
			int cnt = (sum(i, i + m) - k + 1);
			while(cnt){
				i++;
				if(y[i])cnt--;
			}
			i++;
		}else{
			i++;
		}
	}
	cout << ans << '\n';
}


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

int main() {
	int n,m,k;
	cin>>n>>m>>k;
	int arr[n+2];
	for(int i=0;i<n;i++) cin>>arr[i];
	sort(arr,arr+n);
	int i=0,j=0,ans=0,cnt=0;
	queue<int> window = queue<int>();
	for(int i=0;i<n;i++) {
		while(!window.empty() && arr[i]-window.front()>=m) window.pop();

		if(window.size()+1>=k) {
			window.pop_front();
			ans++;
		} else {
			window.push(arr[i]);
		}
	}
	cout<<ans<<"\n";

}


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

int main() {
	int n,m,k;
	cin>>n>>m>>k;
	int arr[n+2];
	for(int i=0;i<n;i++) cin>>arr[i];
	sort(arr,arr+n);
	int i=0,j=0,ans=0,cnt=0;
	deque<int> window = deque<int>();
	for(int i=0;i<n;i++) {
		while(!window.empty() && arr[i]-window.back()>=m) window.pop_back();
		window.push_front(arr[i]);
		if(window.size()>=k) {
			window.pop_front();
			ans++;
		}
	}
	cout<<ans<<"\n";

}


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

int main() {
	int n,m,k;
	cin>>n>>m>>k;
	int arr[n+2];
	for(int i=0;i<n;i++) cin>>arr[i];
	sort(arr,arr+n);
	int i=0,j=0,ans=0,cnt=0;
	queue<int> window = queue<int>();
	for(int i=0;i<n;i++) {
		while(!window.empty() && arr[i]-window.front()>=m) window.pop();

		if(window.size()+1>=k) {
			ans++;
		} else {
			window.push(arr[i]);
		}
	}
	cout<<ans<<"\n";

}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define maxpq priority_queue<ll>
#define minpq priority_queue<ll, vector<ll>, greater<ll> >
#define vi vector<ll>
#define pii pair<ll, ll>
#define vii vector<pii>
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define MOD 1000000007
#define INT_MAXI 9000000000000000000
#define INT_MINI -9000000000000000000

ll max(ll a, ll b) {if (a > b) return a; else return b;}
ll min(ll a, ll b) {if (a < b) return a; else return b;}

const int dx[4] = { -1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
int XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };

int main()
{

	fio;
    ll t,i,j,k,l,n,m;

    cin>>n>>m>>k;
    ll arr[n];
    for(i=0;i<n;i++)
    {
    	cin>>arr[i];
	}
	sort(arr,arr+n);
	i=0,j=0;
	ll count=0,ans=0;
	while(i<n&&j<n)
	{
		ll val=arr[i];
		ll end=arr[i]+m-1;
		while(j<n&&arr[j]<=end)
		{
			count++;
			j++;
		}
	//	cout<<count<<endl;
		if(count>=k)
		{
			ll diff=count-k+1;
			ans+=diff;
			i=j;
			count=0;
		}
		else
		{
			i++;
			count--;
		}

	}
	cout<<ans;

}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define maxpq priority_queue<ll>
#define minpq priority_queue<ll, vector<ll>, greater<ll> >
#define vi vector<ll>
#define pii pair<ll, ll>
#define vii vector<pii>
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define MOD 1000000007
#define INT_MAXI 9000000000000000000
#define INT_MINI -9000000000000000000

ll max(ll a, ll b) {if (a > b) return a; else return b;}
ll min(ll a, ll b) {if (a < b) return a; else return b;}

const int dx[4] = { -1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
int XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };

int main()
{

	fio;
    ll t,i,j,k,l,n,m;

    cin>>n>>m>>k;
    ll arr[n];
    for(i=0;i<n;i++)
    {
    	cin>>arr[i];
	}
	sort(arr,arr+n);
//	cout<<endl;
/*	for(i=0;i<n;i++)
	{
		cout<<arr[i]<<" ";
	}
	cout<<endl;*/
	i=0,j=0;
	ll count=0,ans=0;
	map<ll,ll>mpp;
	while(i<n&&j<n)
	{
		while(mpp.count(i))
		{
		//	ll diff=mpp[i]-i;
		//	count-=diff;
			i=mpp[i];
		}
		ll val=arr[i];
		ll end=arr[i]+m-1;
		while(j<n&&arr[j]<=end)
		{
			count++;
			j++;
		}
	//	cout<<count<<" "<<i<<" "<<j<<endl;
		if(count>=k)
		{
			ll diff=count-k+1;
			ll ind=j-diff;
		//	cout<<ind<<endl;
			mpp[ind]=j;
			ans+=diff;
			i++;
			count-=diff;
			count--;
			if(count<0)
			count=0;
		}
		else
		{
			i++;
			count--;
		}

	}
	cout<<ans;

}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define maxpq priority_queue<ll>
#define minpq priority_queue<ll, vector<ll>, greater<ll> >
#define vi vector<ll>
#define pii pair<ll, ll>
#define vii vector<pii>
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define MOD 1000000007
#define INT_MAXI 9000000000000000000
#define INT_MINI -9000000000000000000

ll max(ll a, ll b) {if (a > b) return a; else return b;}
ll min(ll a, ll b) {if (a < b) return a; else return b;}

const int dx[4] = { -1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
int XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };

int main()
{

	fio;
    ll t,i,j,k,l,n,m;

    cin>>n>>m>>k;
    ll arr[n];
    for(i=0;i<n;i++)
    {
    	cin>>arr[i];
	}
	sort(arr,arr+n);
//	cout<<endl;
/*	for(i=0;i<n;i++)
	{
		cout<<arr[i]<<" ";
	}
	cout<<endl;*/
	i=0,j=0;
	ll count=0,ans=0;
	map<ll,ll>mpp;
	while(i<n&&j<n)
	{
		while(mpp.count(i))
		{
		//	ll diff=mpp[i]-i;
		//	count-=diff;
			i=mpp[i];
		}
		ll val=arr[i];
		ll end=arr[i]+m-1;
		while(j<n&&arr[j]<=end)
		{
			count++;
			j++;
		}
	//	cout<<count<<" "<<i<<" "<<j<<endl;
		if(count>=k)
		{
			ll diff=count-k+1;
			ll ind=j-diff;
		//	cout<<ind<<endl;
			mpp[ind]=j;
			ans+=diff;
			i++;
			count-=diff;
			count--;
		}
		else
		{
			i++;
			count--;
		}

	}
	cout<<ans;

}


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define mp make_pair
#define fi first
#define se second
const int mxn = 1e6 + 10;
vector<int> cnt(mxn, 0);

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		cnt[a]++;
	}
	int ans = 0;
	for (int i = 1; i < mxn; i += m) {
		int sum = 0;
		if (i >= mxn) break;
		for (int j = i; j < min(i + m, mxn); j++)
			sum += cnt[j];
		ans += max(sum - k + 1, 0);
	}
	cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define mp make_pair
#define fi first
#define se second
const int mxn = 1e6 + 10;
vector<int> cnt(mxn, 0);

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		cnt[a]++;
	}
	int ans = 0, sum = 0;
	int l = 1, r = 0;
	while (l < mxn) {
		while (l < mxn && cnt[l] == 0)
			l++, r++;
		while (r < mxn && r - l < m) {
			sum += cnt[++r];
			if (sum == k) sum--, ans++;
		}
		l = r + 1; sum = 0;
	}
	cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define mp make_pair
#define fi first
#define se second
const int mxn = 1e6 + 10;
vector<int> cnt(mxn, 0);

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		cnt[a]++;
	}
	int ans = 0, sum = 0;
	int l = 1, r = 0;
	while (l < mxn) {
		while (l < mxn && cnt[l] == 0)
			l++, r++;
		while (r + 1 < mxn && r - l < m - 1) {
			sum += cnt[++r];
			if (sum == k) sum--, ans++;
		}
		l = r + 1; sum = 0;
	}
	cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define mp make_pair
#define fi first
#define se second
const int mxn = 1e6 + 10;
vector<int> cnt(mxn, 0);

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		cnt[a]++;
	}
	int ans = 0, sum = 0;
	int l = 1, r = 0;
	while (l < mxn) {
		while (l < mxn && cnt[l] == 0)
			l++, r++;
		while (r + 1 < mxn && r - l < m) {
			sum += cnt[++r];
			if (sum == k) sum--, ans++;
		}
		l = r + 1; sum = 0;
	}
	cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define mp make_pair
#define fi first
#define se second
const int mxn = 1e6 + 10;
vector<int> cnt(mxn, 0);

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		cnt[a]++;
	}
	int ans = 0, sum = 0;
	int l = 1, r = 0;
	while (l < mxn) {
		while (r + 1 < mxn && r - l < m - 1) {
			sum += cnt[++r];
			if (sum == k) {
				cnt[r]--;
				sum--, ans++;
			}
		}
		sum -= cnt[l++];
	}
	cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define mp make_pair
#define fi first
#define se second
const int mxn = 1e6 + 10;
vector<int> cnt(mxn, 0);

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		cnt[a]++;
	}
	int ans = 0, sum = 0;
	bool coll = false;
	for (int i = 1; i < mxn;) {
		if (i >= mxn) break;
		if (coll) sum += cnt[min(i + m, mxn)];
		else {
			for (int j = i; j < min(i + m, mxn); j++)
				sum += cnt[j];
		}
		if (sum >= k) {
			ans += sum - k + 1;
			i += m; sum = 0;
			coll = false;
		} else {
			sum -= cnt[i];
			i++; coll = true;
		}
	}
	cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define mp make_pair
#define fi first
#define se second
const int mxn = 1e6 + 10;
vector<int> cnt(mxn, 0);

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		cnt[a]++;
	}
	int ans = 0;
	for (int i = 1; i < mxn; i += m) {
		int sum = 0;
		for (int j = i; j < i + m; j++)
			sum += cnt[j];
		ans += max(sum - k + 1, 0);
	}
	cout << ans << endl;
}


#include <bits/stdc++.h>
#define MAXN 200003
#define MAXV 1000003
#define endl '\n'
using namespace std;
int n, m, k;
bool arr[MAXV];
int last = -1;

void input()
{
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        arr[a] = 1;
        last = max(last, a);
    }
}

void find()
{
    int cnt = 0;
    int lidx = 1;
    int on = 0;
    for (int i = 1; i <= last; i++)
    {
        if (arr[i])
            on++;
        if (i >= m && arr[i - m])
            on--;
        if (on < k)
            continue;
        //cout << i << " " << on << endl;
        on--;
        cnt++;
    }
    cout << cnt << endl;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    input();
    find();

    return 0;
}


#include <bits/stdc++.h>
#define MAXN 200003
#define endl '\n'
using namespace std;
int n, m, k;
int arr[MAXN];
queue <int> q;

void input()
{
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++)
        cin >> arr[i];
}

void find()
{
    sort(arr, arr + n);
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        int prev = max(0, arr[i] - m);
        while (q.size() && q.front() <= prev)
            q.pop();
        if (q.size() + 1 < k)
            q.push(arr[i]);
        else
            cnt++;
    }
    cout << cnt << endl;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    input();
    find();

    return 0;
}


#include <bits/stdc++.h>
#define MAXN 200003
#define endl '\n'
using namespace std;
int n, m, k;
int arr[MAXN];
queue <int> q;

void input()
{
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++)
        cin >> arr[i];
}

void find()
{
    sort(arr, arr + n);
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        int prev = max(0, i - m);
        while (q.size() && q.front() < prev)
            q.pop();
        if (q.size() + 1 < k)
            q.pus(arr[i]);
        else
            cnt++;
    }
    cout << ans << endl;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    input();
    find();

    return 0;
}


#include <bits/stdc++.h>
#define MAXN 200003
#define endl '\n'
using namespace std;
int n, m, k;
int arr[MAXN];
queue <int> q;

void input()
{
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++)
        cin >> arr[i];
}

void find()
{
    sort(arr, arr + n);
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        int prev = max(0, i - m);
        while (q.size() && q.front() < prev)
            q.pop();
        if (q.size() + 1 < k)
            q.push(arr[i]);
        else
            cnt++;
    }
    cout << ans << endl;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    input();
    find();

    return 0;
}


#include <bits/stdc++.h>
#define MAXN 200003
#define endl '\n'
using namespace std;
int n, m, k;
int arr[MAXN];
queue <int> q;

void input()
{
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++)
        cin >> arr[i];
}

void find()
{
    sort(arr, arr + n);
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        int prev = max(0, i - m);
        while (q.size() && q.front() <= prev)
            q.pop();
        if (q.size() + 1 < k)
            q.push(arr[i]);
        else
            cnt++;
    }
    cout << cnt << endl;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    input();
    find();

    return 0;
}


#include <bits/stdc++.h>
#define MAXN 200003
#define MAXV 1000003
#define endl '\n'
using namespace std;
int n, m, k;
bool arr[MAXV];
int last = -1;

void input()
{
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        arr[a] = 1;
        last = max(last, a);
    }
}

void find()
{
    int cnt = 0;
    int on = 0;
    for (int i = 1; i <= last; i++)
    {
        if (on < k)
        {
            if (arr[i])
                on++;
            if (i >= m && arr[i - m])
                on--;
            continue;
        }
        on--;
        cnt++;
        if (arr[i])
            on++;
        if (i >= m && arr[i - m])
            on--;
    }
    cout << cnt << endl;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    input();
    find();

    return 0;
}


#include <bits/stdc++.h>
#define MAXN 200003
#define endl '\n'
using namespace std;
int n, m, k;
int arr[MAXN];
queue <int> q;

void input()
{
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++)
        cin >> arr[i];
}

void find()
{
    sort(arr, arr + n);
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        int prev = max(0, i - m);
        while (q.size() && q.front() < prev)
            q.pop();
        if (q.size() + 1 < k)
            q.push(arr[i]);
        else
            cnt++;
    }
    cout << cnt << endl;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    input();
    find();

    return 0;
}


#include <bits/stdc++.h>
#define MAXN 200003
#define MAXV 1000003
#define endl '\n'
using namespace std;
int n, m, k;
bool arr[MAXV];
int last = -1;

void input()
{
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        arr[a] = 1;
        last = max(last, a);
    }
}

void find()
{
    int cnt = 0;
    int on = 0;
    for (int i = 1; i <= last + 1; i++)
    {
        if (on < k)
        {
            if (arr[i])
                on++;
            if (i > m && arr[i - m])
                on--;
            continue;
        }
        //cout << i << " " << on << endl;
        on--;
        cnt++;
    }
    cout << cnt << endl;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    input();
    find();

    return 0;
}


#include <bits/stdc++.h>
#define MAXN 200003
#define MAXV 1000003
#define endl '\n'
using namespace std;
int n, m, k;
bool arr[MAXV];
int last = -1;

void input()
{
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        arr[a] = 1;
        last = max(last, a);
    }
}

void find()
{
    int cnt = 0;
    int on = 0;
    for (int i = 1; i <= last; i++)
    {
        if (arr[i])
            on++;
        if (i > m && arr[i - m])
            on--;
        if (on < k)
            continue;
        //cout << i << " " << on << endl;
        on--;
        cnt++;
    }
    cout << cnt << endl;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    input();
    find();

    return 0;
}


#include<stdio.h>
#include<algorithm>
#include<set>
#include<string.h>
using namespace std;
int n,m,k;
const int maxn=2e5+10;
int a[maxn];
int vis[maxn];
set<int>s;
int main() {
	scanf("%d %d %d",&n,&m,&k);
	for(int i=1; i<=n; i++)scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	memset(vis,0,sizeof vis);
	int ans=0;
	for(int i=1;i<=n;i++){
		int flag=0;
		if(vis[i]==1)continue;
		int pos=i+k-1;
		if(pos>n)break;
		while(1){
			if(a[pos]<a[i]+m){
				ans++;
				vis[pos]=1;
				pos++;
			}
			else break;
			if(pos>n)break;
		}
	}
	printf("%d\n",ans);}


#include<stdio.h>
#include<algorithm>
#include<set>
#include<string.h>
using namespace std;
int n,m,k;
const int maxn=2e5+10;
int a[maxn];
int vis[maxn];
set<int>s;
int main() {
	scanf("%d %d %d",&n,&m,&k);
	for(int i=1; i<=n; i++)scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	memset(vis,0,sizeof vis);
	int ans=0;
	for(int i=1; i<=n-k+1; i++) {
		int flag=0;
		if(vis[i]==1)continue;
		if(pos>n)break;
		while(1) {
			if(a[pos]<a[i]+m) {
				ans++;
				vis[pos]=1;
				pos++;
			} else {
				pos++;break;
			};
			if(pos>n)break;
		}	if(pos>n)break;
	}
	printf("%d\n",ans);
}


#include<stdio.h>
#include<algorithm>
#include<set>
#include<string.h>
using namespace std;
int n,m,k;
const int maxn=2e5+10;
int a[maxn];
int vis[maxn];
set<int>s;
int main() {
	scanf("%d %d %d",&n,&m,&k);
	for(int i=1; i<=n; i++)scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	memset(vis,0,sizeof vis);
	int ans=0;
	int pos=k;
	if(k==1){
	    printf("%d\n",n);
	    return 0;
	}
	for(int i=1; i<=n-k+1; i++) {
		int flag=0;
		if(vis[i]==1)continue;
		while(1) {
			if(a[pos]<a[i]+m) {
				ans++;
				vis[pos]=1;
				pos++;
			} else {
				pos++;break;
			};
			if(pos>n)break;
		}	if(pos>n)break;
	}
	printf("%d\n",ans);
}


#include<stdio.h>
#include<algorithm>
#include<set>
#include<string.h>
using namespace std;
int n,m,k;
const int maxn=2e5+10;
int a[maxn];
int vis[maxn];
set<int>s;
int main() {
	scanf("%d %d %d",&n,&m,&k);
	for(int i=1; i<=n; i++)scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	memset(vis,0,sizeof vis);
	int ans=0;
	int pos=k;
	for(int i=1; i<=n-k+1; i++) {
		int flag=0;
		if(vis[i]==1)continue;
		while(1) {
			if(a[pos]<a[i]+m) {
				ans++;
				vis[pos]=1;
				pos++;
			} else {
				pos++;break;
			};
			if(pos>n)break;
		}	if(pos>n)break;
	}
	printf("%d\n",ans);
}


#include<stdio.h>
#include<algorithm>
#include<set>
#include<string.h>
using namespace std;
int n,m,k;
const int maxn=2e5+10;
int a[maxn];
int vis[maxn];
set<int>s;
int main() {
	scanf("%d %d %d",&n,&m,&k);
	for(int i=1; i<=n; i++)scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	memset(vis,0,sizeof vis);
	int ans=0;
	for(int i=1; i<=n-k+1; i++) {
		int flag=0;
		if(vis[i]==1)continue;
		while(1) {
			if(a[pos]<a[i]+m) {
				ans++;
				vis[pos]=1;
				pos++;
			} else {
				pos++;break;
			};
			if(pos>n)break;
		}	if(pos>n)break;
	}
	printf("%d\n",ans);
}


#include<stdio.h>
#include<algorithm>
#include<set>
#include<string.h>
using namespace std;
int n,m,k;
const int maxn=2e5+10;
int a[maxn];
int vis[maxn];
set<int>s;
int main() {
	scanf("%d %d %d",&n,&m,&k);
	for(int i=1; i<=n; i++)scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	memset(vis,0,sizeof vis);
	int ans=0;
	for(int i=1;i<=n-k+1;i++){
		int flag=0;
		if(vis[i]==1)continue;
		int pos=i+k-1;
		if(pos>n)break;
		while(1){
			if(a[pos]<a[i]+m){
				ans++;
				vis[pos]=1;
				pos++;
			}
			else break;
			if(pos>n)break;
		}
	}
	printf("%d\n",ans);}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

template <class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_mset;

#define FOR(i,a,b) for(int i = a; i < b; i++)
#define F0R(i,a) for(int i = 0; i < a; i++)
#define F0Rd(i,a) for (int i = a - 1; i >=0 ; i--)
#define FORd(i,a,b) for (int i = b - 1; i >= a; i--)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) int((x).size())
#define newl '\n'

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define print(x) cout << x << newl;
#define finish(x) return cout << x << "\n", 0;
#define bug(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _ << " " <<

const ll MOD = 998244353;
const ll INF = 1e9 + 7;

/*
const int MX = 55;
int parent[MX], sz[MX], vis[MX], n, m, x, y;
vi adj[MX];

void make_set(int v){
	parent[v] = v;
	sz[v] = 1;
}

int find_set(int v){
	if (v == parent[v]) return v;
	return parent[v] = find_set(parent[v]);
}

void union_sets(int a, int b){
	a = find_set(a), b = find_set(b);
	if (a != b){
		if (sz[a] < sz[b]) swap(a,b);
		parent[b] = a;
		sz[a] += sz[b];
	}
}

void dfs(int u, int p){
	vis[u] = 1;
	for (int v : adj[u]){
		if (!vis[v]){
			dfs(v,u);
		}
	}
}

bool works(){
	dfs(1, -1);
	FOR(i,1,n+1){
		if (!vis[i] || sz(adj[i]) != 2) return false;
	}
	return true;
}

bool works2(){
	if (m >= n) return false;
	FOR(i,1,n+1){
		if (sz(adj[i]) > 2) return false;
		vis[i] = 0;
	}
	dfs(1, -1);
}

*/

const int MX = 2e5 + 5;
int n, m, k, a[MX], alarms;
bitset<MX> used;

int main(){ FAST
    //ifstream cin("/Users/konwoo/input.txt");
    //ofstream cout("/Users/konwoo/output.txt");

	cin >> n >> m >> k;
	F0R(i,n) cin >> a[i];
	sort(a,a+n);

	int last = 1;
	set<int> cset;
	F0R(i,n){
		if (used[i]) continue;
		used[i] = 1;
		cset.insert(a[i]);
		if (i >= last) last = i + 1;
		while(last < n && a[last]-a[i]<=m-1){
			if (sz(cset) < k-1){
				cset.insert(a[last]);
			}
			else{
				++alarms;
				used[last] = 1;
			}
			++last;
		}
		//bug(i _ last);
		cset.erase(a[i]);
	}
	finish(alarms);

/*
	cin >> n >> m;
	FOR(i,1,n+1){
		make_set(i);
	}
	F0R(i,m){
		cin >> x >> y;
		adj[x].pb(y); adj[y].pb(x);
		union_sets(x,y);
	}
	if (works()){
		cout << "YES\n" << 0 << newl;
	}
	else{

	}
*/

    return 0;
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

template <class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_mset;

#define FOR(i,a,b) for(int i = a; i < b; i++)
#define F0R(i,a) for(int i = 0; i < a; i++)
#define F0Rd(i,a) for (int i = a - 1; i >=0 ; i--)
#define FORd(i,a,b) for (int i = b - 1; i >= a; i--)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) int((x).size())
#define newl '\n'

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define print(x) cout << x << newl;
#define finish(x) return cout << x << "\n", 0;
#define bug(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _ << " " <<

const ll MOD = 998244353;
const ll INF = 1e9 + 7;

/*
const int MX = 55;
int parent[MX], sz[MX], vis[MX], n, m, x, y;
vi adj[MX];

void make_set(int v){
	parent[v] = v;
	sz[v] = 1;
}

int find_set(int v){
	if (v == parent[v]) return v;
	return parent[v] = find_set(parent[v]);
}

void union_sets(int a, int b){
	a = find_set(a), b = find_set(b);
	if (a != b){
		if (sz[a] < sz[b]) swap(a,b);
		parent[b] = a;
		sz[a] += sz[b];
	}
}

void dfs(int u, int p){
	vis[u] = 1;
	for (int v : adj[u]){
		if (!vis[v]){
			dfs(v,u);
		}
	}
}

bool works(){
	dfs(1, -1);
	FOR(i,1,n+1){
		if (!vis[i] || sz(adj[i]) != 2) return false;
	}
	return true;
}

bool works2(){
	if (m >= n) return false;
	FOR(i,1,n+1){
		if (sz(adj[i]) > 2) return false;
		vis[i] = 0;
	}
	dfs(1, -1);
}

*/

const int MX = 2e5 + 5;
int n, m, k, a[MX], alarms;
bitset<MX> used;

int main(){ FAST
    //ifstream cin("/Users/konwoo/input.txt");
    //ofstream cout("/Users/konwoo/output.txt");

	cin >> n >> m >> k;
	if (k == 1) finish(n);

	F0R(i,n) cin >> a[i];
	sort(a,a+n);

	int last = 1;
	set<int> cset;
	F0R(i,n){
		if (used[i]) continue;
		used[i] = 1;
		cset.insert(a[i]);
		if (i >= last) last = i + 1;
		while(last < n && a[last]-a[i]<=m-1){
			if (sz(cset) < k-1){
				cset.insert(a[last]);
			}
			else{
				++alarms;
				used[last] = 1;
			}
			++last;
		}
		//bug(i _ last);
		cset.erase(a[i]);
	}
	finish(alarms);

/*
	cin >> n >> m;
	FOR(i,1,n+1){
		make_set(i);
	}
	F0R(i,m){
		cin >> x >> y;
		adj[x].pb(y); adj[y].pb(x);
		union_sets(x,y);
	}
	if (works()){
		cout << "YES\n" << 0 << newl;
	}
	else{

	}
*/

    return 0;
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

template <class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_mset;

#define FOR(i,a,b) for(int i = a; i < b; i++)
#define F0R(i,a) for(int i = 0; i < a; i++)
#define F0Rd(i,a) for (int i = a - 1; i >=0 ; i--)
#define FORd(i,a,b) for (int i = b - 1; i >= a; i--)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) int((x).size())
#define newl '\n'

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define print(x) cout << x << newl;
#define finish(x) return cout << x << "\n", 0;
#define bug(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _ << " " <<

const ll MOD = 998244353;
const ll INF = 1e9 + 7;

/*
const int MX = 55;
int parent[MX], sz[MX], vis[MX], n, m, x, y;
vi adj[MX];

void make_set(int v){
	parent[v] = v;
	sz[v] = 1;
}

int find_set(int v){
	if (v == parent[v]) return v;
	return parent[v] = find_set(parent[v]);
}

void union_sets(int a, int b){
	a = find_set(a), b = find_set(b);
	if (a != b){
		if (sz[a] < sz[b]) swap(a,b);
		parent[b] = a;
		sz[a] += sz[b];
	}
}

void dfs(int u, int p){
	vis[u] = 1;
	for (int v : adj[u]){
		if (!vis[v]){
			dfs(v,u);
		}
	}
}

bool works(){
	dfs(1, -1);
	FOR(i,1,n+1){
		if (!vis[i] || sz(adj[i]) != 2) return false;
	}
	return true;
}

bool works2(){
	if (m >= n) return false;
	FOR(i,1,n+1){
		if (sz(adj[i]) > 2) return false;
		vis[i] = 0;
	}
	dfs(1, -1);
}

*/

const int MX = 2e5 + 5;
int n, m, k, a[MX], alarms;

int main(){ FAST
    //ifstream cin("/Users/konwoo/input.txt");
    //ofstream cout("/Users/konwoo/output.txt");

	cin >> n >> m >> k;
	if (k == 1) finish(n);

	F0R(i,n) cin >> a[i];
	sort(a,a+n);

	queue<int> q;
	F0R(i,n){
		while (!q.empty() && a[i] - q.front() >= m) q.pop();
		if (sz(q) == k-1) ++alarms;
		else q.push(a[i]);
	}
	finish(alarms);

/*
	cin >> n >> m;
	FOR(i,1,n+1){
		make_set(i);
	}
	F0R(i,m){
		cin >> x >> y;
		adj[x].pb(y); adj[y].pb(x);
		union_sets(x,y);
	}
	if (works()){
		cout << "YES\n" << 0 << newl;
	}
	else{

	}
*/

    return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
int a[200500],v[200500];
int n,m,k;
int find(int x){
	int l=1,r=n;
	while (l<=r){
		int m=(l+r)>>1;
		if (a[m]<=x) l=m+1;else r=m-1;
	}
	return r;
}
int main(){
	scanf("%d%d%d",&n,&m,&k);
	for (int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	int ans=0;
	for (int i=1;i<=n;i++)
	if (!v[i]) {
		if (a[i]+m>a[i+k-1]) {
			int x=find(a[i]+m);
			for (int j=i+k-1;j<=x;j++)
			if (!v[j])v[j]=1,ans++;
		}
	}
	printf("%d",ans);
	return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
int a[200500],q[200500];
int n,m,k;
int main(){
	scanf("%d%d%d",&n,&m,&k);
	for (int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	int ans=0,head=1,tail=0;
	for (int i=1;i<=n;i++){
		while (head<=tail&&a[i]-a[q[head]]+1>m) head++;
		if (tail-head+1+1<k) q[++tail]=i;else ans++;
	}
	printf("%d",ans);
	return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
int a[200500],v[200500];
int n,m,k;
int find(int x){
	int l=1,r=n;
	while (l<=r){
		int m=(l+r)>>1;
		if (a[m]<=x) l=m+1;else r=m-1;
	}
	return r;
}
int main(){
	scanf("%d%d%d",&n,&m,&k);
	for (int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	int ans=0;
	for (int i=1;i<=n;i++)
	if (!v[i]) {
		if (a[i]+m>a[i+k-1]) {
			int x=find(a[i]+m);
			for (int j=i+k-1;j<=x;j++)
			v[j]=1,ans++;
		}
	}
	printf("%d",ans);
	return 0;
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head

#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif

int n,m,k,a[N],b[N],cnt;

int main() {
	scanf("%d%d%d",&n,&m,&k);
	REP(i,1,n) scanf("%d",a+i);
	sort(a+1,a+1+n);
	REP(i,1,n) {
		int p = upper_bound(b+1,b+1+cnt,a[i]-m)-b;
		if (cnt-p+2<k) b[++cnt] = a[i];
	}
	printf("%d\n",n-cnt);
}


#include <bits/stdc++.h>
using namespace std;
int n,m,k,i,a[222222];
int main() {
	cin>>n>>m>>k;
	for(i=1;i<=n;++i)cin>>a[i];
	sort(a+1,a+1+n);
	for(i=1;i<=n;++i)if(*a+a-upper_bound(a+1,a+1+*a,a[i]-m)+2<k)a[++*a]=a[i];
	cout<<n-*a<<endl;
}


#include <bits/stdc++.h>
using namespace std;
int n,m,k,i,a[22222];
int main() {
	cin>>n>>m>>k;
	for(i=1;i<=n;++i)cin>>a[i];
	sort(a+1,a+1+n);
	for(i=1;i<=n;++i)if(*a+a-upper_bound(a+1,a+1+*a,a[i]-m)+2<k)a[++*a]=a[i];
	cout<<n-*a<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int n,m,k,i,a[222222];
int main() {
	cin>>n>>m>>k;
	for(i=1;i<=n;++i)cin>>a[i];
	sort(a+1,a+1+n);
	for(i=1;i<=n;++i)if(*a+a-upper_bound(a+1,a+1+cnt,a[i]-m)+2<k)a[++*a]=a[i];
	cout<<n-*a<<endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define F(i,a,b) for(int i=int(a);i<=int(b);i++)
#define endl "\n"
#define ios std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define out(x) cout<<x<<endl,exit(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define I first
#define S second

const int N=1e6;
int clk[N+9];

int main(){
	ios;
	int n,m,k,x;
	cin>>n>>m>>k;

	F(i,1,n){
		cin>>x;
		clk[x]++;
	}

	int cur=0;
	F(i,1,m) cur+=clk[i];
	int mx=cur;

	F(i,m+1,N){
		cur-=clk[i-m];
		cur+=clk[i];
		mx=max(mx,cur);
	}

	cout<<max(0,mx-k+1);
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define F(i,a,b) for(int i=int(a);i<=int(b);i++)
#define endl "\n"
#define ios std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define out(x) cout<<x<<endl,exit(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define I first
#define S second

const int N=1e6;
int clk[N+9];

int main(){
	ios;
	int n,m,k,x;
	cin>>n>>m>>k;

	F(i,1,n){
		cin>>x;
		clk[x]++;
	}

	int cur=0,ans=0;
	F(i,1,m) cur+=clk[i];

	int j=m;
	while(cur>=k){
		int tmp=min(clk[j],cur-k+1);
		clk[j]-=tmp;
		ans+=tmp;
		cur-=tmp;
		j--;
	}

	F(i,m+1,N){
		cur-=clk[i-m];
		cur+=clk[i];

		if(cur>=k){
			clk[i]-=cur-k+1;
			ans+=cur-k+1;
			cur=k-1;
		}
	}

	cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define F(i,a,b) for(int i=int(a);i<=int(b);i++)
#define endl "\n"
#define ios std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define out(x) cout<<x<<endl,exit(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define I first
#define S second

int main(){
	ios;
	ll n,m,k,x;
	cin>>n>>m>>k;

	vector <ll> v;
	F(i,1,n){
		cin>>x;
		v.pb(x);
	}

	sort(all(v));

	ll mx=0;
	F(i,0,v.size()-1){
		ll idx=upper_bound(all(v),v[i]+m-1)-v.begin()-1;
		mx=max(mx,idx-i+1);
	}

	cout<<max(0ll,mx-k+1);
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int n,m,k,i,j=0,x,sum=0,cnt=0;
    cin>>n>>m>>k;
    vector<int>vec(n+5, 0);
    for(i=1;i<=n;i++)
    {
        cin>>vec[i];
    }
    for(i=1;i<=n;i++)
    {
       if(vec[i]<=(i+m-1)) cnt++;
       if(cnt==k)
       {
           cnt=0;
           sum++;
           i--;
       }
    }
    cout<<sum<<endl;
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
deque<int>dq;
int main()
{
    int n,m,k,i,mx=-1,x,ans=0;
    cin>>n>>m>>k;
    vector<int>vec(1000005, 0);
    for(i=1;i<=n;i++)
    {
        cin>>x;
        vec[x]++;
        mx = max(mx,x);
    }
    for(i=1;i<=mx;i++)
    {
        if(vec[i]) dq.push_back(i);
        if(dq.size()==k)
        {
            ans++; dq.pop_back();
        }
        while(dq.size() and i-m+1>=dq.front())
        {
            dq.pop_front();
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int n,m,k,x,i,cnt=0,l=2,prev,ans=0,mx=-1;
    cin>>n>>m>>k;
    vector<int>vec(1000005, 0),ind(1000005, 0);
    vec[0] = 0; ind[0] = 0; prev = m;
    for(i=1;i<=n;i++)
    {
        cin>>x;
        vec[x]++;
        mx = max(mx,x);
    }
    for(i=1;i<=mx;i++)
    {
        if(vec[i]) cnt++;
        if(cnt==k && i<=prev)
        {
            if(cnt-1==0) ans+=cnt;
            else ans+=cnt-1;
            cnt--;
        }
        if(i==prev)
        {
            prev = m*l;
            l++; cnt = 0;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int n,m,k,i,j=0,x,sum=0,cnt=0;
    cin>>n>>m>>k;
    vector<int>vec(n+5, 0);
    for(i=1;i<=n;i++)
    {
        cin>>vec[i];
    }
    for(i=1;i<=n;i++)
    {
        x=i; cnt=0;
        for(j=i;j<=n;j++)
        {
            if(vec[j]<=(x+m-1))cnt++;
            if(cnt==k)sum++;
        }
    }
    cout<<sum<<endl;
}


#pragma gcc optimize("O3");
#pragma gcc target("SSE4");
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
int main()
{
	int n, m, k, imin = 0, count = 0;
	cin >> n >> m >> k;
	vector <int> A(n);
	for(int i = 0; i < n; i++)
	{
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	for(int i = 0; i < A.size(); i++)
	{
		while(A[i] - A[imin] >=  m)
		{
			imin ++;
		}
		//cout << i << " " << imin << endl;
		if(i - imin + 1 >= k)
		{
			int count1 = i - imin + 1 - k + 1;
			count += count1;
			//cout << i - count + 1 << " " << i + 1 << endl;
			A.erase(A.begin() + i - count1 + 1, A.begin() + i + 1);
			i -= count1;
		}
	}
	cout << count;
	return 0;
}


#pragma gcc optimize("O3");
#pragma gcc target("SSE4");
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
int main()
{
	int n, m, k, imin = 0, count = 0;
	cin >> n >> m >> k;
	vector <int> A(n);
	for(int i = 0; i < n; i++)
	{
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	set <int> W;
	set <int> :: iterator it;
	for(int i = 0; i < A.size(); i++)
	{
		if(W.size() < k - 1)
		{
			W.insert(A[i]);
			it = W.begin();
		}
		else
		{
			while(*W.end() - *it >= m)
			{
				W.erase(*it);
				it = W.begin();
			}
		//cout << i;
			if(A[i] - *it < m && W.size() >= k - 1)
			{
				count++;
			}
			else
			{
				W.insert(A[i]);
			}
		}
	}
	cout << count;
	return 0;
}


#pragma gcc optimize("O3");
#pragma gcc target("SSE4");
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
int main()
{
	int n, m, k, imin = 0, count = 0, o= -1;
	cin >> n >> m >> k;
	vector <int> A(n);
	for(int i = 0; i < n; i++)
	{
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	set <int> W;
	set <int> :: iterator it;
	for(int i = 0; i < A.size(); i++)
	{
		if(W.size() < k - 1)
		{
			W.insert(A[i]);
			it = W.begin();
			o = A[i];
		}
		else if(W.size() == 0 && k == 1)
		{
			count++;
		}
		else
		{
			while(o - *it >= m)
			{
				//cout << *W.end() << " " << *it << " ";
				W.erase(*it);
				it = W.begin();
			}
		   // cout << i << " " << W.size() << " " << *it;
			if(A[i] - *it < m && W.size() >= k - 1)
			{
				count++;
			//	cout << A[i];
			}
			else
			{
				W.insert(A[i]);
				o = A[i];
			}
		}
	}
	cout << count;
	return 0;
}


#pragma gcc optimize("O3");
#pragma gcc target("SSE4");
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
int main()
{
	int n, m, k, imin = 0, count = 0;
	cin >> n >> m >> k;
	vector <int> A(n);
	for(int i = 0; i < n; i++)
	{
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	set <int> W;
	set <int> :: iterator it;
	for(int i = 0; i < A.size(); i++)
	{
		if(W.size() < k - 1)
		{
			W.insert(A[i]);
			it = W.begin();
		}
		else if(W.size() == 0)
		{
			count++;
		}
		else
		{
			while(*W.end() - *it >= m)
			{
				W.erase(*it);
				it = W.begin();
			}
		//cout << i;
			if(A[i] - *it < m && W.size() >= k - 1)
			{
				count++;
			}
			else
			{
				W.insert(A[i]);
			}
		}
	}
	cout << count;
	return 0;
}


#include <iostream>
#include <vector>
#include <stdio.h>
#include <string.h>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <random>
#include <iomanip>
#include <assert.h>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef double long dl;
typedef unsigned long long ull;

int INF = 2e9;

vector <int> pref(string & s){
    int n = s.size();
    vector<int> g(n, 0);
    for(int i=1; i<n; i++){
        int j = g[i-1];
        while(j>0 and s[i]!=s[j]){
            j=g[j-1];
        }
        if(s[i]==s[j]) j++;
        g[i]=j;
    }
    return g;
}

int N = 3e5+10;
vector<ll> tree;

void build(vector<int> & g, int v, int tl, int tr){
    if(tl==tr) tree[v]=g[tl];
    else{
        int tm=(tl+tr)/2;
        build(g, 2*v, tl, tm);
        build(g, 2*v+1, tm+1, tr);
        tree[v]=max(tree[2*v], tree[2*v+1]);
    }
}

int find_max(int v, int tl, int tr, int l, int r){
    if(l>r) return 0;
    if(tl==l and tr==r) return tree[v];
    int tm = (tl+tr)/2;
    return max(find_max(2*v, tl, tm, l, min(tm, r)),
               find_max(2*v+1, tm+1, tr, max(tm+1, l), r));
}

/*void push(ll v, ll l, ll tm){
    if(tree[v]!=0){
        tree[2*v]=max(tree[v], tree[2*v]);
        tree[2*v+1]=max(tree[v]+tm-l+1, tree[2*v+1]);
        tree[v]=0;
    }
}*/

void update(ll v, ll tl, ll tr, ll pos, ll val){
    if(tl==tr) tree[v]=val;
    else{
        ll tm=(tl+tr)/2;
        if(pos<=tm) update(2*v, tl, tm, pos, val);
        else update(2*v+1, tm+1, tr, pos, val);
        tree[v]=max(tree[2*v], tree[2*v+1]);
    }
}

/*void print_arr(ll v, ll l, ll r){
    if(l==r){
        cout << tree[v] << " ";
    }
    else{
        ll m = (l+r)/2;
        push(v, l, m);
        print_arr(2*v, l, m);
        print_arr(2*v+1, m+1, r);
    }
}*/

ll bin_pow(ll a, ll b, ll m){
    if(b==0) return 1;
    a%=m;
    if(b%2==0){
        return bin_pow(a*a, b/2, m)%m;
    }
    else return (a*bin_pow(a, b-1, m))%m;
}

ull numbers(ull n){
    ull a=0;
    while(n!=0){
        n/=10;
        a++;
    }
    return a;
}

ull num(ull j, ull n1, ull k){
    ull t=0, a=0;
    while(a!=n1-k+1){
        t=j%10;
        j/=10;
        a++;
    }
    return t;
}

char f(string s){
    if(s[0]=='a' and s[1]=='b' or s[1]=='a' and s[0]=='b') return 'c';
    if(s[0]=='a' and s[1]=='c' or s[1]=='a' and s[0]=='c') return 'b';
    if(s[0]=='b' and s[1]=='c' or s[1]=='b' and s[0]=='c') return 'a';
}

vector<int> ssize;
vector<int> parent;
//vector<int> ma;

int find_set(int v){
    if(v==parent[v]){
        return v;
    }
    return parent[v] = find_set(parent[v]);
}

void union_set(int a, int b){
    a = find_set(a);
    b = find_set(b);
    if(a!=b){
        if(ssize[a]<ssize[b]){
            parent[a] = b;
            ssize[b]+=ssize[a];
            //ma[b]=max(ma[a], ma[b]);
        }
        else{
            parent[b] = a;
            ssize[a]+=ssize[b];
            //ma[a]=max(ma[a], ma[b]);
        }
    }
}

void f(int v, int l, int r, int pos){
    if(l==r) tree[v]=1;
    else{
        int m = (l+r)/2;
        if(m>=pos){
            f(2*v+1, l, m, pos);
        }
        else{
            f(2*v+2, m+1, r, pos);
        }
        tree[v]=tree[2*v+1]+tree[2*v+2];
    }
}

int F(int v, int l, int r, int sum) {
    if (l == r) {
        return l;
    }
    int m = (l + r ) / 2;
    if (tree[2 * v + 1] < sum) {
        return F(2 * v + 2, m+1, r, sum - tree[2 * v + 1]);
    }
    else {
        return F(2 * v + 1, l, m, sum);
    }
}

struct wor{
    ll a, b, c, d, e;
};

bool cmp(wor w1, wor w2){
    return w1.a>w2.a;
}

bool cmp1(wor w1, wor w2){
    return w1.b<w2.b;
}

bool cmp2(wor w1, wor w2){
    return w1.c<w2.c;
}

double C_n_k(int n, int k){
    k=max(n-k, k);
    double ans=1;
    int pow_two = n+1;
    for(int i=k+1; i<=n; i++){
        ans*=i;
        while(ans>1e5 and pow_two!=0){
            ans/=2;
            pow_two--;
        }
    }
    for(int i=1; i<=n-k; i++){
        ans/=i;
    }
    while(pow_two!=0){
        ans/=2;
        pow_two--;
    }
    return ans;
}

vector<vector<int>> up;
int l, timer;
void dfs_lca(int v, int p, vector<vector<int>> & g, vector<int> & tinn, vector<int> & toutt){
    tinn[v]=timer;
    timer++;
    up[v][0]=p;
    for(int i=1; i<=l; i++){
        up[v][i]=up[up[v][i-1]][i-1];
    }
    for(int i=0; i<g[v].size(); i++){
        int to = g[v][i];
        if(to==p) continue;
        dfs_lca(to, v, g, tinn, toutt);
    }
    toutt[v]=timer;
}

bool upper(int a, int b, vector<int> & tinn, vector<int> & toutt){
    if(tinn[a]<=tinn[b] and toutt[a]>=toutt[b]){
        return true;
    }
    return false;
}

ll lca(int a, int b, vector<int> & tinn, vector<int> & toutt){
    ll ans=0;
    if(upper(a, b, tinn, toutt)) return 0;
    for(int i=l; i>=0; i--){
        if(!upper(up[a][i], b, tinn, toutt)){
            a=up[a][i];
            ans+=(1<<i);
        }
    }
    ans+=1;
    return ans;
}

ll phi(ll n){
    ll ans=n;
    for(ll i=2; i*i<=n; i++){
        if(n%i==0){
            while(n%i==0){
                n/=i;
            }
            ans-=ans/i;
        }
    }
    if(n!=1){
        ans-=ans/n;
    }
    return ans;
}

/*bool operator<(wor w1, wor w2){
    return w1.c>w2.c;
}*/

int main() {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie(0);
    cout.tie(0);
    //freopen("lazy.in", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
    ll n, m, k;
    cin >> n >> m >> k;
    vector<int> g(n);
    for(int i=0; i<n; i++){
        cin >> g[i];
    }
    sort(g.begin(), g.end());
    set<int> s;
    ll ans=0;
    for(int i=0; i<n; i++){
       if(s.size()==0){
            s.insert(g[i]);
       }
       else{
            while(s.size()!=0 and *s.begin()+m-1<g[i]){
                s.erase(s.begin());
            }
            if(s.size()==k-1){
                ans++;
            }
            else {
                s.insert(g[i]);
            }
       }
    }
    cout << ans;
    return 0;
    //system( "pause" );
}