#include <stdio.h>
//#include <conio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
char *n1="input.txt", *n2="output.txt", s, s_p, *buf=""; //clrscr();
int kol=0;   int flag=0, i=0;
FILE *f1;
FILE *f2;
f1=fopen(n1, "r");
f2=fopen(n2, "w");
if (f1)
	{
	rewind(f1);
	while (!feof(f1))
		{
		fread (&s, sizeof(char), 1, f1);
		//printf("%c",s);getche();  clrscr();
		if (flag==0)
			{
			flag=1;
			s_p=s;
			}
		if (s==s_p)
			{
			kol++;
			}
		else
			{
			char *q="";q[0]=s_p; int cifra=atoi(q);
			itoa (kol,buf,10);
			fwrite (buf, sizeof(buf), 1, f2);
			itoa (cifra,buf,10);
			fwrite (buf, sizeof(buf), 1, f2);
			s_p=s; kol=1;
			}
		}
	kol--; // uchityvaem simvol konca stroki
	char *q="";q[0]=s_p; int cifra=atoi(q);
	itoa (kol,buf,10);
	fwrite (buf, sizeof(buf), 1, f2);
	itoa (cifra,buf,10);
	fwrite (buf, sizeof(buf), 1, f2);
	}
else printf  ("ego net");
fclose (f1);
fclose (f2);
return 0;
exit(1);
}