I can not figure out the runtime error for this program. The link to the question: link
#include <stdio.h>
int main()
{
int i,j,k,count,N,M[100];
char L[100];
while ((scanf("%d",&N))!=EOF)
{for(i=0;i<N;i++)
scanf("%d %c",&M[i],&L[i]);
j=0;
k=1;
count=0;
while(j<N)
{for(i=k;i<N;i++)
{if((M[j]==M[i])&&(L[j]!=L[i]))
++count;
if((M[j]==M[i])&&(L[j]==L[i]))
M[i]=0;
}
++k;
++j;
}
printf("%d\n",count);
}
return 0;
}