#include <stdio.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; char q[1]="0";
FILE *f1;
FILE *f2;
f1=fopen(n1, "r");
f2=fopen(n2, "w");
if (f1)
	{
	rewind(f1);
	while (!feof(f1))
		{
		fread (&s, 1, 1, f1);
		if (flag==0)
			{
			flag=1;
			s_p=s;
			}
		if (s==s_p)
			{
			kol++;
			}
		else
			{
			 q[0]=s_p;//int cifra=atoi(q);
			//itoa (kol,buf,10);
			if (kol==1000) buf="1000";
			if (kol>=100)
				{
				 switch(kol/100)
					{
					case 0: buf[i]='0';break;
					case 1: buf[i]='1';break;
					case 2: buf[i]='2';break;
					case 3: buf[i]='3';break;
					case 4: buf[i]='4';break;
					case 5: buf[i]='5';break;
					case 6: buf[i]='6';break;
					case 7: buf[i]='7';break;
					case 8: buf[i]='8';break;
					case 9: buf[i]='9';break;
					}

				 kol/=10;
				}
			if(kol>=10&&kol<100)
				{

				switch(kol/10)
					{
					case 0: buf[i]='0';break;
					case 1: buf[i]='1';break;
					case 2: buf[i]='2';break;
					case 3: buf[i]='3';break;
					case 4: buf[i]='4';break;
					case 5: buf[i]='5';break;
					case 6: buf[i]='6';break;
					case 7: buf[i]='7';break;
					case 8: buf[i]='8';break;
					case 9: buf[i]='9';break;
					}
				i++;kol/=10;
				}
			if (kol<10)
				{
				 switch (kol)
					{
					case 0: buf[i]='0';break;
					case 1: buf[i]='1';break;
					case 2: buf[i]='2';break;
					case 3: buf[i]='3';break;
					case 4: buf[i]='4';break;
					case 5: buf[i]='5';break;
					case 6: buf[i]='6';break;
					case 7: buf[i]='7';break;
					case 8: buf[i]='8';break;
					case 9: buf[i]='9';break;
					}
				}
			fwrite (buf, 1, 1, f2);
			//itoa (cifra,buf,10);
			/*switch (cifra)
				{
				case 0: buf[0]='0';break;
				case 1: buf[0]='1';break;
				case 2: buf[0]='2';break;
				case 3: buf[0]='3';break;
				case 4: buf[0]='4';break;
				case 5: buf[0]='5';break;
				case 6: buf[0]='6';break;
				case 7: buf[0]='7';break;
				case 8: buf[0]='8';break;
				case 9: buf[0]='9';break;
				}  */
			fwrite (q, 1, 1, f2);
			s_p=s; kol=1;
			}
		}
	kol--; // uchityvaem simvol konca stroki
	char *q="";q[0]=s_p; int cifra=atoi(q);
	//
		if (kol==1000) buf="1000";
			if (kol>=100)
				{
				 switch(kol/100)
					{
					case 0: buf[i]='0';break;
					case 1: buf[i]='1';break;
					case 2: buf[i]='2';break;
					case 3: buf[i]='3';break;
					case 4: buf[i]='4';break;
					case 5: buf[i]='5';break;
					case 6: buf[i]='6';break;
					case 7: buf[i]='7';break;
					case 8: buf[i]='8';break;
					case 9: buf[i]='9';break;
					}

				 kol/=10;
				}
			if(kol>=10&&kol<100)
				{

				switch(kol/10)
					{
					case 0: buf[i]='0';break;
					case 1: buf[i]='1';break;
					case 2: buf[i]='2';break;
					case 3: buf[i]='3';break;
					case 4: buf[i]='4';break;
					case 5: buf[i]='5';break;
					case 6: buf[i]='6';break;
					case 7: buf[i]='7';break;
					case 8: buf[i]='8';break;
					case 9: buf[i]='9';break;
					}
				i++;kol/=10;
				}
			if (kol<10)
				{
				 switch (kol)
					{
					case 0: buf[i]='0';break;
					case 1: buf[i]='1';break;
					case 2: buf[i]='2';break;
					case 3: buf[i]='3';break;
					case 4: buf[i]='4';break;
					case 5: buf[i]='5';break;
					case 6: buf[i]='6';break;
					case 7: buf[i]='7';break;
					case 8: buf[i]='8';break;
					case 9: buf[i]='9';break;
					}
				}
	fwrite (buf, 1, 1, f2);
	//itoa (cifra,buf,10);
	fwrite (q, 1, 1, f2);
	//fwrite (buf, sizeof(buf), 1, f2);
	}
else printf  ("ego net");
fclose (f1);
fclose (f2);
return 0;
exit(1);
}