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

int main()
{
char *n1="input.txt", *n2="output.txt", s, s_p;
int kol=0;   int flag=0, i=0; char *q="";
FILE *f1;
FILE *f2;
f1=fopen(n1, "rt");
f2=fopen(n2, "wt");
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;
			fprintf (f2, "%d",kol);
			fwrite (q, 1, 1, f2);
			s_p=s; kol=1;
			}
		}
	kol--; // uchityvaem simvol konca stroki
	q[0]=s_p;
	fprintf (f2, "%d",kol);
	fwrite (q, 1, 1, f2);
	}
else printf  ("ego net");
fclose (f1);
fclose (f2);
return 0;
exit(1);
}