#include<stdio.h>
#include<string.h>
int main()
{
    int i,c=0,l,s=0,n;
    scanf("%d",&n);
    char str[n];
    scanf("%s",str);
    l=strlen(str);
    for(i=0;i<l;)
    {
        if(str[i]=='U' && str[i+1]=='R')
        {
            c++;
            i=i+2;
        }
        else if(str[i]=='R' && str[i+1]=='U')
        {
            c++;
            i=i+2;
        }
        else i++;
    }
    printf("%d",n-c);
    return 0;
}

/*Problem 954A Diagonal Walk*/
#include <stdio.h>
int main()
{
    int n, moves, i;
    char str[100];
    scanf("%d", &n);
    scanf("%s", str);
    moves = n;

    for (i = 0; i < n; i++)
    {
        if (i == n - 1)
            break;
        if (str[i] != str[i + 1])
        {
            moves--;
            i++;
        }
    }
    printf("%d", moves);
    return 0;
}

#include <stdio.h>
typedef float fl;
typedef char ch;
typedef long long ll;
#define rep(i,a,n) for(i=a;i<n;i++)
#define rev(i,n,a) for(i=n;i>=a;i--)
#define repr(i,a,b) for(i=a;i<b;i++)
#define s(n) scanf("%d",&n);
#define s2(n,m) scanf("%d%d",&n,&m);
#define s3(n,m,o) scanf("%d%d%d",&n,&m,&o);
#define p(n) printf("%d",n);
#define p2(n,m) printf("%d%d",n,m);
#define sc(n) scanf("%c",&n);
#define sf(n) scanf("%f",&n);
#define sl(n) scanf("%lld",&n);
#define pc(n) printf("%c",n);
#define pf(n) printf("%f",n);
#define pl(n) printf("%lld",n);
#define br break;
#define co continue;
#define ss(a) scanf("%s",&a);
#define ps(a) printf("%%s",a);
#define nl printf("\n");
#define r0 return 0;
int main()
{
    int n;
    s(n)
    ch a[n];
    ss(a)
    int i,y=0,z=0;
    for(i=0;i<n-1;)
    {
        if(a[i]=='U'&&a[i+1]=='R')
        {
            y++;
            i+=2;
        }
        else if(a[i]=='R'&&a[i+1]=='U')
        {
            y++;
            i+=2;
        }
        else
            i++;
    }
    p(n-y)
	r0
}

#include <stdio.h>

int main()
{
    int n, cnt = 0;
    char str[101];
    scanf("%d %s", &n, str);
    for(int i = 1; str[i]; ++i) {
        if(str[i] != str[i - 1]) {
            str[i] = str[i + 1];
            ++cnt;
        }
    }
    printf("%d\n", n - cnt);
    return 0;
}

#include <stdio.h>

int main()
{
    int n, i, ans=0;
    char s[101];
    scanf("%d %s", &n, s);
    for(i=0; i<n; i++)
    {
        if(s[i] != s[i+1])
            ans++, i++;
        else
            ans++;
    }
    printf("%d\n", ans);

    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    int a,b,c,i;
    scanf("%d", &a);
    int m=a;
    getchar();
    char ar[a];
    gets(ar);

    for(i=0; i<a; i++)
    {
        if(i+1<a&&ar[i] != ar[i+1])
        {
            m--;
            i++;
        }
    }
    printf("%d\n", m);
}

#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    char a[n];
    scanf("%s",a);
    int i;
    int b=n;
    for(i=0;i<b-1;i++){
        if(a[i]!=a[i+1]){
            --n;
            i++;
        }
    }
    printf("%d",n);
    return 0;
}

#include <stdio.h>

int main()
{
    int n, j=0;
    scanf("%d", &n);
    char a[n+2];
    scanf("%s", a);
    for(int i=0; i<n-1; i++)
    {
        if(a[i]!=a[i+1])
        {
           j++;
           i++;
        }
    }
    printf("%d", n-j);
}

/*
 * diagonalwalk.c
 *
 * Copyright 2019 Ravi Teja <Ravi Teja@DESKTOP-NNTRDO1>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 *
 *
 */

#include <stdio.h>

int main(int argc, char **argv)
{ int n,i,c=0;
	scanf("%d",&n);
	char a[n];
	scanf("%s",a);
	for(i=0;i<n-1;i++){
		if(a[i]!=a[i+1]){
			c=c+1;
			i=i+1;
		}
	}
	printf("%d",n-c);

	return 0;
}

#include<stdio.h>
int main()
{
    int n,i,count=0;
    scanf("%d",&n);
    char s[n+1];
    scanf("%s",&s);
    for(i=0;i<n;i=i+0)
    {
        if(s[i]=='U')
        {
            if(s[i+1]=='R')
            {
                count=count+1;
                i=i+2;
            }
            else
            {
                i=i+1;
            }
        }
        else if(s[i]=='R')
        {
            if(s[i+1]=='U')
            {
                count=count+1;
                i=i+2;
            }
            else
            {
                i=i+1;
            }
        }
    }
    printf("%d",n-count);
}

#include<stdio.h>
#include<string.h>
int main(void)
{
    int n;
    scanf("%d",&n);
    scanf("%*c");
    char str[n+1];
    gets(str);
    int i,j,k,l;
    for(i=0; i<n; i++)
    {
        if((str[i]=='R' && str[i+1]=='U') || (str[i]=='U' && str[i+1]=='R'))
        {
            str[i]='1';
            str[i+1]='D';
        }
    }
    int count=0;
    for(i=0; i<n; i++)
    {
        if(str[i]=='U' || str[i]=='D' || str[i]=='R')
        {
            count++;
        }
    }
    printf("%d",count);
    return 0;
}

#include<stdio.h>
#include<conio.h>

int main()
{
   char str[100];
   int len,ctr,count=0;
   scanf("%d",&len);
   scanf("%s",str);
   for( ctr = 0 ; ctr < len; )
   {
       if( str[ctr+1] != NULL )
       {
       if( str[ctr] == 'U'&& str[ctr+1] == 'R')
         {
             count++;
             ctr+=2;
         }
        else if( str[ctr] == 'R' && str[ctr+1]== 'U')
        {
            count++;
            ctr+=2;
        }
        else
        {
            ctr++;
            count++;
        }
       }
       else
       {
       count++;
       ctr++;
       }
   }

   printf("%d",count);
}

#include<stdio.h>
int main()
{
int n,i,c=0;
char s[100];
scanf("%d",&n);
scanf("%s",s);
for(i=1;i<n;i++)
{
	if(s[i]!=s[i-1])
	{
	    i++;
	    c++;
	}
}
printf("%d",n-c);
return 0;
}

#include <stdio.h>
int main()
{
    int i,n,count=0;
    scanf("%d",&n);
    char s[n];
    scanf("%s",s);
    for(i=0;s[i]!='\0';i++)
    {
        if(s[i]=='U')
        {
            if(s[i+1]=='R')
            {
                count++;
                i++;
            }
            else
                count++;
        }
        else if(s[i]=='R')
        {
            if(s[i+1]=='U')
            {
                count++;
                i++;
            }
            else
                count++;
        }
    }
    printf("%d\n",count);
    return 0;
}

#include <stdio.h>
#include<string.h>
int main()
{
	int i=0,count=0,n=0;
        scanf("%d",&n);
	char s[n];
	scanf("%s",s);
	for(i=0;i<n;)
	{
	if(s[i]=='U' && s[i+1]=='R'){
	 count++;i=i+2;
	}
        else if(s[i]=='R' && s[i+1]=='U')
	{
         count++;
	 i=i+2;
	}
        else{
	 count++;
	 i++;
	}}
        printf("%d",count);

}

#include<stdio.h>
int main()
{
    int n,i,count=0;
    char str[319];
    scanf("%d",&n);
    scanf("%s",str);
    for(i=0;i<n;i++)
        if(str[i]=='R' && str[i+1]=='U' || str[i]=='U' && str[i+1]=='R')
            str[i+1]='0';

    for(i=0;i<n;i++)
        if(str[i]!='0') count++;

    printf("%d",count);
    return 0;
}

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

int main()
{
  int n;
  scanf("%d",&n);
  char* s=(char*)malloc(sizeof(char)*n);
  int i,c=n;
  for(i=0;i<n;i++)
    scanf(" %c",&s[i]);
  for(i=0;i<n;++i)
  {
    if((s[i]=='R' && s[i+1]=='U')||(s[i]=='U' && s[i+1]=='R'))
    {c--; i++;}
  }
  printf("%d",c);
  return 0;
}

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

char a[200];
int main()
{
    int n,sum1= 0,sum2=0;
    scanf("%d",&n);
    scanf("%s",a);
    for(int i = 0 ; i < n; i++)
    {
        int k;
        if(!sum2)
        {
            if(a[i]=='U')
                sum2 = 1;
            else sum2 = 2;
            sum1++;
        }
        else
        {
            if(a[i] == 'U')
                k = 1;
            else k = 2;
            if(k!=sum2){
                sum2 = 0;
            }
            else
                sum1++;
        }
    }
    printf("%d\n",sum1);
}

#include <stdio.h>
#include<string.h>
void check_replace(char *s)
 {
     while(*s!='\0')
     {
         if(*s=='U')
         {
             if(*(s+1)=='R')
             {
                *s='D';
                char *p=s+1;
                while(*p!='\0') {*p=*(p+1);p++;}
             }
             else
                s++;
         }
         else if (*s=='R')
         {
             if(*(s+1)=='U')
             {
                 *s='D';
                 char *p=s+1;
                 while(*p!='\0') {*p=*(p+1);p++;}
             }
             else
                s++;
         }
         else
            s++;
     }
 }
int main(void) {

	int n;
	scanf("%d",&n);
	char s[n];
	scanf("%s",s);

	check_replace(s);
	printf("%d",strlen(s));

	return 0;
}

int main() {
	long n, len, i,NUM;
	scanf("%ld", &n);
	char str[101];
	scanf("%s", str);
	for (i = 0; i < n - 1; i++)
		if (str[i] != str[i + 1]&&str[i]!='D') {
			str[i] = 'n';
			str[i + 1] = 'D';
		}
	NUM = 0;
	for (i = 0; i < n; i++)
		if (str[i] != 'n')
			NUM++;
	printf("%ld\n", NUM);
	return 0;
}

#include <stdio.h>

int main()
{
	int n;
	char mt[150];
	scanf("%d", &n);
	scanf("%s", &mt, 150);
	int num;
	num = n;
	int i;
	for (i = 0; i < n - 1; i++)
	{
		if (mt[i] != mt[i + 1])
		{
			num -= 1;
			i += 1;
		}
	}
	printf("%d", num);
}

#include<stdio.h>
int main()
{
    int n,i,count=0,cout,out,result;
    scanf("%d",&n);
    char s[n];
    scanf("%s",&s);
    for(i=0;i<n;i++)
    {
        if(s[i]=='R'&& s[i+1]=='U')
        {
            count++;
            i++;
        }
        else if(s[i]=='U'&& s[i+1]=='R')
        {
            count++;
            i++;
        }}

        /*if(s[i]=='u'&& s[i+1]=='r' && s[i+2]=='u')
        {
            count--;
        }*/

    cout=count*2;
    result=n-cout;
    out=result+count;
    printf("%d",out);
    return 0;
}

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

int main()
{
    int n, count=0;
    scanf("%d", &n);
    char str[n+2];
    scanf("%s", str);  // 0 hole unchecked
    int len= strlen(str);

    int flag[n];
    memset(flag, 0, n*sizeof(int));

   for(int i=0 ; i<len ; i++){
        if((str[i]=='R' && str[i+1]== 'U')||(str[i]== 'U' && str[i+1]== 'R')){
            if(flag[i]==0 && flag[i+1]==0){
                count++;
                flag[i]=1;
                flag[i+1]=1;
            }
        }
    }

    printf("%d", n-count);

    return 0;
}

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

int main()
{
    int i,n,ans=0;
    char letters[100000];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf(" %c",&letters[i]);
    }
    for(i=0;i<n;i++)
    {
      if(letters[i]=='R'&&letters[i+1]=='U')
      {
          ans++;
          i++;
          continue;
      }
      if(letters[i]=='U'&&letters[i+1]=='R')
      {
          ans++;
          i++;
          continue;
      }
      ans++;
    }
    printf("%d",ans);
    return 0;
}

#include<stdio.h>
int main (){
    int n,i,all;
    char tit[101];
    scanf("%d",&n);
    all=0;
    getchar();
    gets(tit);
    for(i=0;i<strlen(tit)-1;){
        if(tit[i]!=tit[i+1]){
            i+=2;
            all++;
        }
        else
            i++;
    }
    printf("%d",n-all);
}

#include<stdio.h>
char a[101];
int s=0,i=0,n;
int main()
{
scanf("%d",&n);
scanf("%s",a);
while (i<n)
   {
   	if (a[i]==a[i+1])
   	   {
   	   s++;
   	   i++;
   	   }
   	   else
   	   {
   	   	s++;
   	   	i+=2;
   	   }
   }
   printf("%d",s);

   return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    int a,s,d,f,g,h,j,k,l;
    scanf("%d",&a);
    d=a;
    char lol[a+1];
    scanf("%s",&lol);
    for(s=0;s<a-1;s++)
    {
        if(lol[s]!=lol[s+1])
            d--,s++;
    }
    printf("%d",d);
}

#include <stdio.h>

int main(){
    int i,n,hasilD = 0,hasil = 0;
    scanf("%d",&n);
    char arr[n];
    scanf("%s",&arr);

    for(i = 0 ;i<n-1;i++){
        //printf("I SEKARANG : %d\n",i);
        if(arr[i] != arr[i+1]){
            hasilD++;
            i++;
        }

        }
    printf("%d",n-hasilD);
    return 0;
}

//http://codeforces.com/contest/954/problem/A
#include<stdio.h>
#include<math.h>
#include<string.h>
#define False 0
#define True 1
// int small(char ch)
// int capital(char ch);
// int prime(int number);
// void bubble_sort(int arr[], int n);
//void upper(char *ptr);
//void lower(char *ptr);
// void sort(char *ptr, int n);
// void RemoveDuplicates(char * arr, char * new_str, int arr_size);
// int Contains(char * arr, char elem, int arr_size);
// int Times_of_shapes(char * str, int len);

int main(void)
{

    int number, move=0, i;
    char str[101];
    scanf("%d", &number);
    scanf("%s", str);
    for(i=0;i<number;)
    {
    	if(str[i]==str[i+1])
    	{
    		move++;
    		i++;
    	}
    	else
    	{
    		i+=2;
    		move++;
    	}
    }
    printf("%d\n", move);

	return 0;
}

// int Times_of_shapes(char * str, int len)
// {

// 	int j, i, times=0, result=0;
// 	str[len]='\0';
// 	char temp[len][len+1];
// 	for(i=0;i<=len;i++)
// 	{
// 		temp[0][i]=str[i];
// 	}
// 	for(i=1;i<len;i++)
// 	{
// 		temp[i][0]=temp[i-1][len-1];
// 		for(j=1;j<len;j++)
// 		{
// 			temp[i][j]=temp[i-1][j-1];
// 		}
// 		temp[i][len]='\0';
// 	}

// 	for(i=0;i<len;i++)
// 	{
// 		times=0;
// 		for(j=i+1;j<len;j++)
// 		{
// 			if(strcmp(temp[i], temp[j])==False)
// 			{
// 				times++;
// 			}
// 		}
// 		if(times==False)
// 		{
// 			result++;
// 		}
// 	}
// 	return result;

// }

// int Contains(char * arr, char elem, int arr_size)
// {

//     int index = 0;

//     for(index = 0; index < arr_size; index++)
//     {

//         if(arr[index] == elem)
//         {
//             return True;
//         }
//     }

//     return False;

// }

// void RemoveDuplicates(char * arr, char * new_str, int arr_size)
// {

//     int index = 0, new_index = 0;

//     //clear temp string
//     for(index = 0; index < arr_size; index++)
//     {
//         new_str[index] = 0;
//     }

//     for(index = 0; index < arr_size; index++)
//     {

//         if(Contains(new_str, arr[index], arr_size) == False)
//         {
//             new_str[new_index] = arr[index];
//             new_index++;
//         }
//         if(index==arr_size-1)
//         {
//             new_str[new_index]='\0';
//         }
//     }

// }

// void sort(char *ptr, int n)
// {
// 	int i, j, temp;
// 	for(i=0;i<n-1;i++)
// 	{
// 		for(j=0;j<n-i-1;j++)
// 		{
// 			if(ptr[j]>ptr[j+1])
// 				{
// 					temp=ptr[j];
// 					ptr[j]=ptr[j+1];
// 					ptr[j+1]=temp;
// 				}

// 		}
// 	}

// }

/*
void upper(char *ptr)
{
	int i=0;
	while(ptr[i]!='\0')
	{
		if(ptr[i]>='a'&&ptr[i]<='z')
			ptr[i]-=32;
		i++;
	}

}*/

/*
void lower(char *ptr)
{
	int i=0;
	while(ptr[i]!='\0')
	{
		if(ptr[i]>='A'&&ptr[i]<='Z')
			ptr[i]+=32;
		i++;
	}
}*/

// void bubble_sort(int ptr[], int n)
// {
// 	int i, j, temp;
// 	for(i=0;i<n-1;i++)
// 	{
// 		for(j=0;j<n-i-1;j++)
// 		{
// 			if(ptr[j]>ptr[j+1])
// 				{
// 					temp=ptr[j];
// 					ptr[j]=ptr[j+1];
// 					ptr[j+1]=temp;
// 				}

// 		}
// 	}

//  }

// int capital(char ch)
// {
// 	int flag=0;
// 	if(ch>=65&&ch<=90)
// 		flag=1;
// 	return flag;

// }

// int small(char ch)
// {
// 	int flag=0;
// 	if(ch>='a'&&ch<='z')
// 		flag=1;
// 	return flag;

// }
// int prime(int number)
// {
// 	int flag=1, i;
// 	for(i=2;i<=number/2;i++)
// 	{
// 		if(number%i==0)
// 		{
// 			flag=0;
// 			break;
// 		}
// 	}
// 	if(number<=1)
// 		flag=1;
// 	return flag;
// }

#include<stdio.h>
#include<string.h>
int main()
{
    int n,n1,count=0,x;
    char s[101];
    scanf("%d ",&n);

    for(int i=0;i<n;i++)
    {
        scanf("%c",&n1);
        s[i]=n1;
    }
    for(int j=0;j<n;j++)
    {
        x=j+1;
        for(int k=x;k<=x;k++)
        {

            if(s[j]==s[k])
            {
                count++;
            }
            else{
                j++;
                count++;
            }
        }
    }
    printf("%d\n",count);
    return 0;

}

#include<stdio.h>
#include<string.h>
int main ()
{
    int i,count=0,n,j,k ;

    scanf("%d",&n) ;
    char s[n] ;
    scanf("%s",s) ;

    j=strlen(s) ;

    for(i=0;s[i]!='\0';i++)
    {
        if(s[i]=='R'&& s[i+1]=='U'||s[i]=='U'&& s[i+1]=='R')
           {
               count++ ;
               i++ ;
           }

         //  printf("%d   ",count ) ;
    }
    //printf("\n%d",count+1) ;
    k= j-count ;

    printf("%d",k) ;

    return 0 ;
}

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

void countCon(char *arr, int n);

int main(void){
  int n;
  scanf("%d", &n);
  char *path = (char *) malloc(sizeof(char) * (n + 1));
  scanf("%s", path);
  countCon(path, n);
}

void countCon(char *arr, int n){
  int i = 0;
  int count = 0;
  while(i < n - 1){
    if((int)*(arr+i) != (int)*(arr+i+1)){
      count++;
      i += 2;
    }
    else {
      i++;
    }
  }
  printf("%d\n", (n - count));
}

#include<stdio.h>

int main(){
	int n;
	scanf("%d",&n);
	char data[n];
	scanf("%s",data);
	char prev = data[0];
	int cnt=0;
	for(int i=1;i<n;i++){
		if(data[i]!=prev){
			cnt++;
			i++;
			prev = data[i];
		}
	}
	printf("%d",n-cnt);
	return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
	int n;
	scanf("%d", &n);

	char a[n];
	scanf("%s", a);

	int i, count=0, pair=0, solo=0;

	i=0;
	//printf("\n%d %d %d %d",i ,n , pair, solo);

	while(n>0)
	{
		if(a[i]=='R')
		{
			if(a[i+1]=='U')
			{
				pair++;
				n--;
				i++;
			}
			else if(a[i+1]=='R')
				solo++;
			else
				solo++;
		}
		else if(a[i]=='U')
		{
			if(a[i+1]=='R')
			{
				pair++;
				n--;
				i++;
			}
			else if(a[i+1]=='U')
				solo++;
			else
				solo++;
		}
		n--;
		i++;
		//printf("\n%d %d %d %d",i ,n , pair, solo);
	}
	count=pair+solo;
	printf("\n%d", count);
}

#include<string.h>
#include<stdio.h>
int main()
{
int n,i=0,mov=0;
scanf("%d",&n);
char str[n];
scanf("%s",str);
	while(i<n)
{

	if((str[i]=='U'&& str[i+1]=='R')||(str[i]=='R'&& str[i+1]=='U'))
	{
	       mov++;
		i=i+2;
	}
	else{
		mov=mov+1;;
		i++;
	   }
	}
printf("%d",mov);
return 0;

}

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

int main(){

    char str[100];
    int count=0,i,n;
    scanf("%d",&n);
    scanf("%s",str);
    for(i=0;i<n-1;){
        if((str[i]=='R' && str[i+1]!='R') || (str[i]=='U' && str[i+1]!='U')){
        i=i+2;
        count++;
        }
        else{
            i++;
        }
    }
printf("%d\n",n-count);
    return 0;
}

#include<stdio.h>
#include<string.h>
#define ll long long
#define MAX 101
int main()
{
	int n,ans=0;
	scanf("%d",&n);
	char str[n];
	scanf("%s",&str);
	for(int i=0;i<n;)
	{
		if(str[i]==str[i+1])
		{
		i++;
		ans++;
	    }
	    else if(str[i]!=str[i+1])
	    {
	    i+=2;
	    ans++;
		}
    }
    printf("%d\n",ans);
	return 0;
}

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

int main()
{
    int n,i,count=0;
    scanf("%d",&n);
    getchar();
    char ch[n+5];
    gets(ch);
    for(i=0;i<n;i++)
    {
        if((ch[i]=='U' && ch[i+1]=='R') || (ch[i]=='R' && ch[i+1]=='U'))
        {
            count++;
            i=i+1;
        }
    }
    printf("%d\n",n-count);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int fun(char *,int );
int fun(char *s,int n)
{
    int i=0,cnt=n;
    while(i<n-1)
    {
        if(s[i]!=s[i+1])
        {
            cnt--;
            i=i+2;
        }
        else
        {
            i++;
        }
    }
    return cnt;
}
int main()
{
    char a[101];
    int n;
    scanf("%d%s",&n,a);
    printf("%d\n",fun(a,n));
    return 0;
}

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

int main()
{
	int n,i,j ;
	char ch[1000], ch1[1000]="";
	do {scanf("%d",&n);} while((n<1)||(n>100));
	int b = 0 ;
	do
	{i=0 ;
	scanf("%s",ch);
		while(i<strlen(ch))
			if ((ch[i] == 'U') || (ch[i] == 'R')) {i++; b=1; } else {b=0; break ;}
	} while((b==0) || (strlen(ch) != n)) ;
	i=0 ;
	j=0;

	while(i<n) {
			if(ch[i] != ch[i+1]){strcat(ch1,"D") ; i=i+2; j++;}
			else{ch1[j]=ch[i] ; i++ ;j++;}

	 }
	int k = strlen(ch1);
	printf("%d",k);

return 0 ;
}

#include <stdio.h>

#include <string.h>

int main()

{

    int n , count = 0 ;

    scanf("%d",&n) ; char ch = getchar() ;

    char ara[n] ;

    scanf("%[^\n]",ara) ;

    if( n == 1 )  {

        printf("1\n") ;

        return 0 ;

    }

    else  {

        for( int a = 0 ; a < (n-1) ; a++ )  {

if( (ara[a] == 'R' && ara[a+1] == 'U' ) || (ara[a] == 'U' && ara[a+1] == 'R' ) )  {

                count++ ; a+=1 ;

            }

        }
       // printf("%d\n",count) ;
        printf("%d\n",n-count) ;

    }

    return 0 ;

}

#include <stdio.h>
int main()
{
    int n,i,j,count=0;
    scanf("%d",&n);
    char ch[n];
    getchar();
    gets(ch);
    for(i=0;i<n;i++)
    {
        if(ch[i]!=ch[i+1])
        {
            i++;
        }
        count++;
    }
    printf("%d",count);
}

#include <stdio.h>

int main()
{
    int n,i,c;
    char inp[150];
    scanf("%d",&n);
    getchar();
    if((n>=1)&&(n<=100))
{   for(i=0;i<n;i++) scanf("%c",&inp[i]);
    for(i=0;i<n;i++)
    {
        if((inp[i]=='R')&&(inp[i+1]=='U')) { c++; i++; }
        else if((inp[i]=='U')&&(inp[i+1]=='R')) { c++; i++; }
        else { c++;}
    }
    printf("%d",c);
}   else printf("Enter the sequence between 1 to 100");
    return 0;
}

#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
    int n,k=0,i,j;
    scanf("%d",&n);
    char S[n];
    scanf("%s",&S);
    for(i=0;i<n;i++)
    {
        if((S[i]=='U'&&S[i+1]=='R')||(S[i]=='R'&&S[i+1]=='U'))
        {
            k++;
            i++;
        }
    }
    printf("%d\n",n-k);
    return 0;
}

#include<stdio.h>
int main()
{
    int i,n;
    char ch[101];
    scanf("%d",&n);

    scanf("%s",&ch);

    for(i=0;ch[i]!='\0';i++)  //condition is not i<n caz n will be decreased
    {
        if(ch[i]=='R' && ch[i+1]=='U')
        {
            n--;
            i++;
        }
        else if(ch[i]=='U' && ch[i+1]=='R')
        {
            n--;
            i++;
        }
    }
    printf("%d",n);
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    int i,n,sum=0;
    char a[110];
    scanf("%d",&n);
    scanf("%s",a);

    for(i=0;i<n-1;)
    {
        if(a[i]!=a[i+1])
        {
            sum=sum+1;
            i=i+2;

        }
        else{i++;}

    }
    printf("%d",n-sum);
    return 0;
}

#include <stdio.h>
#define MAX 107

int main()
{
	int i, n, c = 0;
	char str[MAX];
	scanf("%d", &n);
	scanf("%s", str);
	for(i=0;i<n-1;++i)
	{
		if((str[i] == 'U' && str[i + 1] == 'R') || (str[i] == 'R' && str[i + 1] == 'U'))
		{
			++i;
			++c;
		}
	}
	printf("%d\n", n - c);
	return 0;
}

#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	int i,sum=0;
	char a='D',b;
	getchar();
	for(i=0;i<n;i++)
	{

		scanf("%c",&b);
		if((a=='U'&&b=='R')||(a=='R'&&b=='U'))
		{
			a='D';
		}
		else
		{
			a=b;
			sum++;
		}
	}
	printf("%d\n",sum);
	return 0;
}

#include<stdio.h>
#define sf scanf
#define pf printf
int main()
{
    int n,i,count=0;
    sf("%d",&n);
    char s[n];
    sf("%s",s);
    for(i=1;i<n;i++)
    {
        if(s[i]!=s[i-1])
        {
            i++;
            count++;
        }
        //pf("%d\n",count);
    }
    pf("%d",n-count);
}

#include <stdio.h>

int main()
{
	int n,c=0;
	scanf("%d",&n);
	char a[n];
	scanf("%s",a);
	for(int i=0;i<n-1;i++)
	{
		if(a[i]!=a[i+1])
		{
			c++;
			i++;
		}

	}
	printf("%d",n-c);
	return 0;
}

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

int main()
{
    int a,b,i,counter=0;
    scanf("%d",&a);
    char strng[a],result[a];

    scanf("%s",strng);

    for(i=0;i<strlen(strng);i++)
    {
        if(strng[i]=='R'&& strng[i+1]=='U' || strng[i]=='U'&& strng[i+1]=='R')
        {
            strng[i+1]='N';
        }
        if(strng[i]!='N')
        {
            counter++;
        }
    }

    printf("%d\n",counter);
    return 0;

}

#pragma warning(disable:4996)
#include <stdio.h>
#include <malloc.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#define N 100
#define EPS 1E-5
//#define min(a,b) (a>b) ? b : a
int lol(const void *x1, const void *x2)
{
	return *(int*)x1 - *(int*)x2;
}
/*
int gcd(int a, int b)
{
	int c;
	while (b)
	{
		c = a % b;
		a = b;
		b = c;
	}
	return a;
}*/
int Min(int a, int b)
{
	return (a > b) ? b : a;
}
int main(void)
{
	char ch[101], c;
	int n, i = 0, count = 0;
	scanf("%i%c", &n, &c);
	do
	{
		scanf("%c", &c);
		if (c != '\n')
			ch[i++] = c;
	} while (c != '\n');
	ch[i] = c;
	for (i = 0; i<n; i++)
	{
		if (ch[i] == 'U' && ch[i + 1] == 'R' || ch[i] == 'R' && ch[i + 1] == 'U')
			i++;
		count++;
	}
	printf("%i", count);
	return 0;
}

#include<stdio.h>
int main()
{
    int i,j=0,k=0,n,U,R;
	char a[100];

	scanf("%d %s",&n,a);

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

	if(a[i]!=a[j])
	{
	k++;
	j++;
	break;
	}

	else
	break;
		}
	}
	printf("%d",n-k);
	return 0;

}

#include <stdio.h>
#include <stdbool.h>

#define minimum(x,y)((x)<(y) ? (x) : (y))
#define maximum(x,y)((x)>(y) ? (x) : (y))

int main()
{
    int n,i,res;
    bool wait;

    res = 0;
    wait = true;

    scanf("%d",&n);
    char s[n+1];
    for(i=0;i<n+1;i++){
        scanf("%c", &s[i]);
        // printf("%c and %d and %s PUTTED\n", s[i],i,(wait)?"True":"False");
        if((!(s[i]==s[i-1]))&&(wait)&&(i>1)){
            // printf("%c c %d\n", s[i],i);
            // printf("%c pc %d\n", s[i-1],i);
            res++;
            wait = false;
        }else{
            wait = true;
        }
    }
    printf("%d",n-res);

    return 0;
}

#include<stdio.h>
int main(){
	int leng,count=0,i=0;
	scanf("%d",&leng);
	char s[leng];
	scanf("%s",s);
	while(i<leng){
		if(s[i]!=s[i+1]){
			count++;i=i+2;
		}else if(s[i]==s[i+1]){
			count++;i++;
		}
	}
	printf("%d",count);
}

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

int main (void){
  char* path;
  int n,i,cnt=0;
  scanf("%d",&n);
  path=(char*)calloc(n,sizeof(char));
  getchar();
  scanf("%s",path);
  for(i=0;i<n;i++){
    if(path[i]==path[i+1])
      cnt++;
    else{
      cnt++;
      i++;
    }
  }
  printf("%d",cnt);
  return 0;
}

#include<stdio.h>
#include<string.h>
int main() {
	int l;
	scanf("%d",&l);
	char ss[102];
	scanf("%s",ss);
	int b;
	b = strlen(ss);
	int a = 1;
	for(int i = 0; i < b - 1; i++) {
		if(ss[i] == 'R' && ss[i + 1] =='U') {
			i++;
		}
		else if(ss[i] == 'U' && ss[i + 1] == 'R') {
			i++;
		}
		a++;
	}
	printf("%d\n",a);

	return 0;

}

#include <stdio.h>

int main(){
    int i,n,hasilD = 0,hasil = 0;
    scanf("%d",&n);
    char arr[n];
    scanf("%s",&arr);

    for(i = 0 ;i<n-1;i++){
        printf("I SEKARANG : %d\n",i);
        if(arr[i] != arr[i+1]){
            hasilD++;
            i++;
        }

        }
    printf("%d",n-hasilD);
    return 0;
}

#include<stdio.h>
int main()
{
	int n,i,j,k=0;
	scanf("%d",&n);
	char a[n];
	fflush(stdin);
	for(i=0;i<n;i++)
	{
		scanf("%c",&a[i]);
	}j=0;
while(j<n-1)
	{
		if(a[j]!=a[j+1])
		{
			k++;
			j++;

		}
		j++;
	}
	printf("%d",n-k);
	return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,l,s=0,c=0;
    scanf("%d",&n);
    char str[n];
    scanf("%s",str);
    l=strlen(str);
    //printf("%d %d",n,l);
    for(i=0;i<l;i++)
    {
        if(str[i]!=str[i+1])
        {
            c++;
        }
    }
    if(c%2!=0)
    {
        c=(c/2)+1;
    }
    else if(c%2==0)
    {
        c=c/2;
    }
    printf("%d",n-c);
    return 0;
}

#include<stdio.h>
int main()
{
    int i,n,sum=0;
    char a[110];
    scanf("%d",&n);
    for(i=0;i<n-1;i++)
    {
        scanf("%c",&a[i]);
    }
    for(i=0;i<n-1;i++)
    {
        if(a[i]!=a[i+1])
        {
            sum=sum+1;
            i++;
        }
    }
    printf("%d",n-sum);
    return 0;
}

#include<stdio.h>
int main()
{
    int n,i,count=0,cout,out,result;
    scanf("%d",&n);
    char s[n];
    scanf("%s",&s);
    for(i=0;i<n;i=i+2)
    {
        if(s[i]=='r'&& s[i+1]=='u')
        {
            count++;
        }
        else if(s[i]=='u'&& s[i+1]=='r')
        {
            count++;
        }}

        /*if(s[i]=='u'&& s[i+1]=='r' && s[i+2]=='u')
        {
            count--;
        }*/

    cout=count*2;
    result=n-cout;
    out=result+count;
    printf("%d",out);
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    char a[100];
    int i,l,p=0;

  gets(a);

     for(i=0;i<strlen(a);)
    { if(a[i]!=a[i+1])
    {
        i=i+2;
         p++;
    }

        else if(a[i]=='U'||a[i]=='R')
        {
            p++;
            i++;
        }

    }

    printf("%d",p);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main()
{

    unsigned char n , i=0;
    char *s;
    scanf("%d",&n);
    s=(char*)malloc(sizeof(char)*n);
    scanf("%s",s);
    int nbre = n;
    while(i<n-1)
    {
        if((s[i]=='U'&&s[i+1],'R')||(s[i]=='R'&&s[i+1]=='U'))
        {
            i+=2;
            nbre--;
        }
        else i++;
    }
    printf("%d",nbre);
}

#include<stdio.h>
int main()
{
    int n,i,count=0;
    scanf("%d",&n);
    char s[n+1];
    scanf("%s",&s);
    for(i=0;i<n;i=i+1)
    {
        if(s[i]=='U')
        {
            if(s[i+1]=='R')
            {
                count=count+1;
                i=i+2;
            }
            else
            {
                i=i+1;
            }
        }
        else if(s[i]=='R')
        {
            if(s[i+1]=='U')
            {
                count=count+1;
                i=i+2;
            }
            else
            {
                i=i+1;
            }
        }
    }
    printf("%d",n-count);
}

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

int main()
{
	int n,i,j ;
	char ch[100], ch1[100]="";
	do {scanf("%d",&n);} while((n<1)||(n>100));
	int b = 0 ;
	do
	{i=0 ;
	scanf("%s",ch);
		while(i<strlen(ch))
			if ((ch[i] == 'U') || (ch[i] == 'R')) {i++; b=1; } else {b=0; break ;}
	} while((b==0) || (strlen(ch) != n)) ;
	i=0 ;
	j=0;

	while(i<n) {
			if(ch[i] != ch[i+1]){strcat(ch1,"D") ; i=i+2; j++;}
			else{ch1[j]=ch[i] ; i++ ;j++;}

	 }
	int k = strlen(ch1);
	printf("%d",k);

return 0 ;
}

#include <stdio.h>

int main() {
    int a;
    scanf("%d",&a);
    int x=a%2;
    printf("%d", x);
}

#include<stdio.h>
#include<string.h>
int main() {
	int l;
	scanf("%d",&l);
	char ss[102];
	for(int i = 0; i < l; i++) {
		scanf("%c", &ss[i]);
	}

	int a = 1;
	for(int i = 0; i < l - 1; i++) {
		if(ss[i] == 'R' && ss[i + 1] =='U') {
			i++;
		}
		else if(ss[i] == 'U' && ss[i + 1] == 'R') {
			i++;
		}
		a++;
	}
	printf("%d\n",a);
	return 0;

}

#include<stdio.h>
#include<conio.h>

int main()
{
   char str[100];
   int len,ctr,count=0;
   scanf("%d",&len);
   scanf("%s",str);
   for( ctr = 0 ; ctr < len; )
   {
       if( str[ctr+1] != NULL )
       {
       if( str[ctr] == 'U'&& str[ctr+1] == 'R')
         {
             count++;
             ctr+=2;
         }
        else if( str[ctr] == 'R' && str[ctr+1]== 'U')
        {
            count++;
            ctr+=2;
        }
        else
        ctr++;
       }
       else
       {
       count++;
       ctr++;
       }
   }

   printf("%d",count);
}

#include <stdio.h>

int main() {
    int n,l=0;
    char m[100];

    scanf("%d",&n);
    scanf("%s",m);

    for(int i=0;i<n-1;i++){
        if(m[i]!=m[i+1])
            l++; i++;
    }

    printf("\n%d",n-l);
}

#include <stdio.h>
#include <stdbool.h>

#define minimum(x,y)((x)<(y) ? (x) : (y))
#define maximum(x,y)((x)>(y) ? (x) : (y))

int main()
{
    int n,i,res;
    bool wait;

    res = 0;
    wait = true;

    scanf("%d",&n);
    char s[n];
    for(i=0;i<n;++i){
        scanf("%c", &s[i]);
        // printf("%c PUTTED\n", s[i]);
        if((!(s[i]==s[i-1]))&&(wait)&&(i>1)){
            // printf("%c c %d\n", s[i],i);
            // printf("%c pc %d\n", s[i-1],i);
            res++;
            wait = false;
        }else{
            wait = true;
        }
    }
    printf("%d",n-res);

    return 0;
}

//
// cout << m-arrSum;

#include <stdio.h>

int main() {
    int a,x;
    scanf("%d",&a);
    x=a%2;
    printf("%d", x);
}

#include<stdio.h>

int main()
{
	int n,moves=0,i;

	scanf("%d", &n);
	char walk[n];

	scanf("%s", walk);

	for(i=0;i<n;){
		printf("i=%d", i);
		if ( (i==(n-1)))
		{
			moves++;
			break;
		}
		if(walk[i]=='U'){
			if(walk[i+1]=='R'){
				moves+=1;
				i=i+2;
			}
			else{
				moves++;
				i++;
			}
		}
		if(walk[i]=='R'){
			if(walk[i+1]=='U'){
				moves+=1;
				i=i+2;
			}
			else{
				moves++;
				i++;
			}
		}
	}

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

#include<stdio.h>
#include<conio.h>

int main()
{
   char str[100];
   int len,ctr,count=0;
   scanf("%d",&len);
   scanf("%s",str);
   for( ctr = 0 ; ctr < len-1; )
   {
       if( str[ctr+1] != NULL )
       {
       if( str[ctr] == 'U'&& str[ctr+1] == 'R')
         {
             count++;
             ctr+=2;
         }
        else if( str[ctr] == 'R' && str[ctr+1]== 'U')
        {
            count++;
            ctr+=2;
        }
        else
        ctr++;
       }
       else count++;
   }

   printf("%d",count);
}

#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    char s[n+1];
    scanf("%s",s);
    int i=0;
    int e=0;
    for(i=1;i<n;)
    {
        if(s[i]!=s[i-1])
            {
                if(i==n-2)
                    e++;
            i+=2;
            }
        else{
            i++;}
            e++;
    }
    printf("%d",e);
}

#include<stdio.h>
int main()
{
    int i,n,sum=0;
    char a[110];
    scanf("%d",&n);
    for(i=0;i<n-1;i++)
    {
        scanf("%c",&a[i]);
    }
    for(i=0;i<n-1; )
    {
        if(a[i]!=a[i+1])
        {
            sum=sum+1;
            i=i+2;
        }
        else{i++; }

    }
    printf("%d\n",sum);
    printf("%d",n-sum);
    return 0;
}

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

int main()
{
	int n,i,j ;
	char ch[100], ch1[100];
	do {scanf("%d",&n);} while((n<1)||(n>100));
	int b = 0 ;
	do
	{i=0 ;
	scanf("%s",ch);
		while(i<strlen(ch))
			if ((ch[i] == 'U') || (ch[i] == 'R')) {i++; b=1; } else {b=0; break ;}
	} while((b==0) || (strlen(ch) != n)) ;
	i=0 ;
	j=0;
	while(i<n) {
			if(ch[i] != ch[i+1]){strcat(ch1,"D") ; i=i+2; j++;}
			else{ch1[j]=ch[i] ; i++ ;j++;}

	 }
	int k = strlen(ch1);
	printf("%d",k);

return 0 ;
}

#include<stdio.h>
int main()
{
    int a;
    char b[101];

    scanf("%d",&a);
    scanf("%s",b);

    for(int i=0;i<a-1;i++)
    {
        if(b[i]!=b[i+1])
            a--;

    }

    printf("%d\n",a);
    return 0;

}

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

int main()
{
  int n;
  scanf("%d",&n);
  char* s=(char*)malloc(sizeof(char)*n);
  int i,c=n;
  for(i=0;i<n;i++)
    scanf(" %c",&s[i]);
  for(i=0;i<n;++i)
  {
    if((s[i]=='R' && s[i+1]=='U')||(s[i]=='U' && s[i+1]=='R'))
    c--;
  }
  printf("%d",c);
  return 0;
}

#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    char s[n+1];
    scanf("%s",s);
    int i=0;
    int e=0;
    for(i=1;i<n;)
    {
        if(s[i]!=s[i-1])
            i+=2;
        else{
            i++;}
            e++;
    }
    printf("%d",e);
}

#include<stdio.h>
#include<string.h>
int main()
{
    int i,j=0,n,count=0;
    char s[101],a[101];
    scanf("%d",&n);
    getchar();
    gets(s);
    for(i=0;i<strlen(s);i++)
    {
        if(s[i]=='U'&&s[i+1]=='R'||s[i]=='R'&&s[i+1]=='U')
        {
              a[j]='D';
              i++;
              j++;
        }
        else
            a[i]=s[i];
    }
    printf("%d",strlen(a));
}

#include <stdio.h>

int main(int argc, char **argv)
{ int n,i,c=0;
	scanf("%d",&n);
	char a[n];
	scanf("%s",a);
	for(i=0;i<n-1;i++){
		if(a[i]!=a[i+1]){
			c=c+1;
			i=i+1;
		}
	}
	printf("%d",c);

	return 0;
}

#include<stdio.h>

int main(){
	int n;
	scanf("%d",&n);
	char data[n];
	scanf("%s",data);
	char prev = data[0];
	int cnt=0;
	for(int i=1;data[i];i++){
		if(data[i]!=prev){
			cnt++;
			i++;
			prev = data[i];
		}
	}
	printf("%d",n-cnt);
	return 0;
}

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

int main()
{
    int n,i,count=0;
    scanf("%d",&n);
    char s[1005];
    gets(s);
    for(i=0;i<n;i++)
    {
        if((s[i]=='U' && s[i+1]=='R') || (s[i]=='R' && s[i+1]=='U'))
        {
            count++;
            i=i+1;
        }
    }
    printf("%d\n",n-count);
    return 0;
}

#include<stdio.h>
int main(void)
{
char arr[101];
int sum=0, i=0;
scanf("%s", &arr);
while(arr[i]!='\0')
{
if(arr[i]==arr[i+1])
{
sum++;
i++;
}
else
{
sum++;
i+=2;
}
}
printf("%d\n", sum);

return 0;
}

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

int main()
{
    int n, count = 0 , h = 0;
    scanf("%d",&n);
    char stri[100];
    scanf("%s",&stri);
    for(int i = 0; i<strlen(stri)-1; i++)
    {
        if(stri[i]!= stri[i+1])
        {
            count++;
            i++;
        }
        else
            h++;
    }
    printf("%d",count+h+1);
    return 0;

}

#include <stdio.h>

int main(void){
	int maxstep;
	scanf("%d", &maxstep);
	char lalala[101] = {0};
	for(int i = 0; i < maxstep+1; i ++){
		scanf("%c", &lalala[i]);
		printf("%c", lalala[i]);
	}
	int discount = 0;
	for(int i = 1; i < maxstep; i ++){
		if(lalala[i] != lalala[i+1]){
			discount += 1;
			i += 1;
			// printf("%d",i);
		}
	}
	printf("%d", maxstep - discount);
}

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

int main(){
  int n,i,count=0;
  scanf("%d",&n);
  char a[n];
  scanf("%s",a);
  for(i=1;i<n;i++){
    if(a[i]=='U'&&a[i+1]=='R'||a[i]=='R'&&a[i+1]=='U'){
      i++;
      count++;
    }
  }
  //printf("count=%d\n",count);
  printf("%d",n-count);
  return 0;
}

#include <stdio.h>

int main(){
    int i,n,hasilD = 0,hasil = 0;
    scanf("%d",&n);
    char arr[n];
    scanf("%s",&arr);

    for(i = 0 ;i<n-1;i++){
        printf("I SEKARANG : %d\n",i);
        if(arr[i] != arr[i+1]){
            hasilD++;
            i++;
        }

        }
    printf("%d",n-hasilD);
    return 0;
}

#include <stdio.h>

int main()
{
    int n, cnt = 0;
    char str[101];
    scanf("%d %s", &n, str);
    for(int i = 1; str[i]; ++i) {
        if(str[i] != str[i - 1]) {
            ++cnt;
            ++i;
        }
    }
    printf("%d\n", n - cnt);
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    int i,n,sum=0;
    char a[110];
    scanf("%d",&n);
    scanf("%s",a);

    for(i=0;i<n-1;)
    {
        if(a[i]!=a[i+1])
        {
            sum=sum+1;
            i=i+2;

        }
        i++;

    }
    printf("%d",n-sum);
    return 0;
}

#include<stdio.h>
int main()
{
	int n,i,j,k=0;
	scanf("%d",&n);
	char a[n];
	fflush(stdin);
	for(i=0;i<n;i++)
	{
		scanf("%c",&a[i]);
	}j=0;
while(j<n-1)
	{
		if(a[j]!=a[j+1])
		{
			k++;
			j++;

		}
		j++;
	}
	printf("%d",n-k);
	return 0;
}

#include <stdio.h>
#include <math.h>

int main(){
	char c[105];
	int i,n;
	int count;
	while(~scanf("%d",&n)){
		scanf("%s",&c);
		count=0;
		for(i=0; i<n-1; i++){
			if(abs(c[i]-c[i+1]) == 3){
				i+=2;
				count++;
			}
		}
		printf("%d\n",n-count);
	}
	return 0;
}

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

char array[128] = {0};

int main(void){
	int n, ans = 0;
	scanf("%d",&n);
	scanf("%s",array);
	puts("haha");
	for(int i=0;i<n-1;i++)
		if(array[i] != array[i+1])
			ans += 1, i++;

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

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

int main()
{
    int num, count, i;
    char name[101], temp;

    while(scanf("%d %s", &num, &name) == 2){
        count = 1;
        temp = name[0];
        int flag = 0;
        for(i=1; i< strlen(name); i++){
            if((name[i]=='R' && temp == 'U') || (name[i] == 'U' && temp == 'R') && flag == 0){
                temp = name[i];
                flag = 1;
                continue;
            }
            else{
                count++;
                temp = name[i];
                flag = 0;
            }
        }
        printf("%d\n", count);
    }

    return 0;
}

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

int main()
{
    int n,i,count=0;
    scanf("%d",&n);
    getchar();
    char ch[n+5];
    gets(ch);
    for(i=0;i<n;i++)
    {
        if((ch[i]=='U' && ch[i+1]=='R') || (ch[i]=='R' && ch[i]=='U'))
        {
            count++;
        }
    }
    printf("%d\n",n-count);
    return 0;
}

#include<stdio.h>
int main()
{
    int a;
    char b[101];

    scanf("%d",&a);
    scanf("%s",b);

    for(int i=0;i<a-1;i++)
    {
        if(b[i]!=b[i+1])
            a--;

    }

    printf("%d\n",a);
    return 0;

}

#include<stdio.h>

int main(void)
{
	int num = 0;
	int j = 0;
	int TotalNunmber = 0;

	scanf("%d", &num);
	TotalNunmber = num;
	char abc[100];
	for (int i = 0; i <= num; i++)
	{
		scanf("%c", &abc[i]);
	}

	for (int i = 1; i <= num; i++)
	{
		if (abc[i] == 'R')
		{
			int j = i + 1;
			if (abc[j] == 'U')
			{
				TotalNunmber--;
				int k = j + 1;
				if (abc[k] == 'R')
				{
					TotalNunmber++;
					int u = k + 1;
					if (abc[u] == 'U')
					{
						TotalNunmber--;
					}
				}
			}
		}
		if (abc[i] == 'U')
		{
			int j = i + 1;
			if (abc[j] == 'R')
			{
				TotalNunmber--;
				int k = j + 1;
				if (abc[k] == 'U')
				{
					TotalNunmber++;
				}
			}

		}
	}

	printf("%d", TotalNunmber);

}

#include <stdio.h>

int main(){
    int i,n,hasilD = 0;
    scanf("%d",&n);
    char arr[n];
    scanf("%s",&arr);

    for(i = 0 ;i<n;i++){
        if(arr[i] != arr[i+1]){
            hasilD++;
            i+=2;
        }
    }
    printf("%d",n-hasilD);
    return 0;
}


/* practice with Dukkha */
#include <stdio.h>

long long lucky(int b) {
	return b == 1 ? 0 : lucky(b / 2) * 10 + (b % 2 == 0 ? 4 : 7);
}

long long solve(int r) {
	long long n_, sum;
	int b;

	n_ = 0, sum = 0;
	for (b = 2; ; b++) {
		long long n = lucky(b);

		if (n < r) {
			sum += (n - n_) * n;
			n_ = n;
		} else {
			sum += (r - n_) * n;
			break;
		}
	}
	return sum;
}

int main() {
	int l, r;

	scanf("%d%d", &l, &r);
	printf("%lld\n", solve(r) - solve(l - 1));
	return 0;
}

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

char c[11]={0};

long long arr[100000];
int counter= 0;
void permutate(int i,int d);
int binser(int x,int h);

int main()
{
    int i=0;
    for(i=0;i<=9;i++)
    {
        permutate(0,i);
    }
    arr[counter]=4444444444;
    long long  beg,last;
    unsigned long long sum=0;
    scanf("%I64d %I64d",&beg,&last);
    int index=binser(beg,counter);
    while(beg<=last)
    {
        if(arr[index]<last)
        {
            sum+=(arr[index]*(arr[index]-beg+1));
        }
        else
        {
            sum+=(arr[index]*(last-beg+1));
        }
            index++;
        beg=arr[index-1]+1;
    }
    printf("%I64d",sum);
    return 0;
}
void permutate(int i,int d)
{
    if(i==d)
    {
        c[d+1]='\0';

        sscanf(c,"%I64d",&arr[counter++]);
        return;
    }
    c[i]='4';
    permutate(i+1,d);
    c[i]='7';
    permutate(i+1,d);
    return ;
}
int binser(int x,int h)
{
    int l=0;
    while(l<h)
    {
        int mid=l+(h-l)/2;
        if(arr[mid]>=x&&arr[mid-1]<x)
            return mid;
        else if(arr[mid]>x)
            h=mid-1;
        else
            l=mid+1;
    }
    if(arr[l]>=x&&arr[l-1]<x)
        return l;

}

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void gen(long long int *a)
{
  int i;
  a[2]=4;
  a[3]=7;
  for(i=2;i<=2048;i++){
    //heaps are beautiful
    a[i<<1]=a[i]*10+4;
    a[(i<<1)+1]=a[i]*10+7;
    //      printf("%lld %lld\n",a[i<<1],a[(i<<1)+1]);
  }
}
int main()
{
  long long int b[10000],*a;
  long long int ans,till;
  int l,r,i;
  gen(b);
  a=b+2;//the first two indices of b contain junk
  scanf("%d%d",&l,&r);
  i=0;
  while(a[i]<l)
    i++;
  till=((r>=a[i])?a[i]:r);
  ans=a[i]*(till-l+1);
  //   printf("%lld+",ans);

  for(i=i+1;a[i]<=r;i++)
    ans+=(a[i]*(a[i]-a[i-1]));
  if(a[i-1]<r)
    ans+=(a[i]*(r-a[i-1]));
  // printf("%lld\n",ans);
  printf("%I64d\n",ans);
  return 0;
}

#include<stdio.h>
#define N 10000000000ll
__int64 a[10000],queue[10000];
int main()
{
    int l,r,front=0,rear=0,i=1,j,ji,k,flag;
    __int64 sum,temp;
    queue[rear++]=4;
    queue[rear++]=7;
    a[0]=0;
    while(i)
    {
        temp=queue[front];
        front++;
        a[i]=temp;
        if(a[i]>N) break;
        i++;
        queue[rear++]=temp*10+4;
        queue[rear++]=temp*10+7;
    }
    while(~scanf("%d%d",&l,&r))
    {
        sum=flag=0;
        if(l==r)
        {
            for(j=1;;j++)
            if(l>a[j-1]&&l<=a[j]) {ji=j;sum+=a[ji];break;}
            printf("%I64d\n",sum);
            continue;
        }
        for(j=1;;j++)
        {
            if(l>a[j-1]&&l<=a[j]) {ji=j;sum+=(a[ji]-l+1)*a[ji];break;}
        }
        for(j=ji;;j++)
        if(r>a[j-1]&&r<=a[j]) break;
        if(j==ji)
        {
            sum=(r-l+1)*a[j];
            printf("%I64d\n",sum);
            continue;
        }
        if(r!=a[j]) j-=1;
        for(k=ji+1;k<=j;k++)
        sum+=(a[k]-a[k-1])*a[k];
        sum+=(r-a[j])*a[j+1];
        printf("%I64d\n",sum);
    }
    return 0;
}

#include<stdio.h>
main()
{
    long long l,r,power=10;
    scanf("%I64d%I64d",&l,&r);
    int END=8190;
   long long no[20000];
   no[0]=4,no[1]=7;int i,j,start=0,counter=2;
   while(start<END)
   {
    for(i=4;i<=7;i+=3)
   {
       {
        for(j=start;j<start*2+2;j++)
                no[counter++]=i*power+no[j];
       }
    }
    start=start*2+2;
    power=power*10;
   }
start=0;long long sum=0;
while(start<END&&l>no[start])
    start++;
long long prev_no=l;
while(start<END&&r>no[start])
{
    sum+=no[start]*(no[start]-prev_no+1);
    prev_no=no[start]+1;
    start++;
}
sum+=no[start]*(r-prev_no+1);
printf("%I64d",sum);
return 0;
}

#include <stdio.h>

typedef __int64 ll;

ll lucky[3000];
ll q[10000];

int init()
{
    ll f = 0, r = 0, ret = 0;
    const ll limit = 4444444444ll;
    q[r++] = 4;
    q[r++] = 7;
    while (f < r)
    {
        lucky[ret++] = q[f];
        if (q[f] * 10 + 4 <= limit)
        {
            q[r++] = q[f] * 10 + 4;
        }
        if (q[f] * 10 + 7 < limit)
        {
            q[r++] = q[f] * 10 + 7;
        }
        f++;
    }
    return ret;
}

ll count(ll m, int n)
{
    int i;
    ll ret = 0;
    for (i = 0; i < n; i++)
    {
        if (i == 0)
        {
            if (lucky[i] <= m)
            {
                ret += lucky[i] * lucky[i];
            }
            else
            {
                ret += lucky[i] * m;
            }
        }
        else
        {
            if (lucky[i] <= m)
            {
                ret += lucky[i] * (lucky[i] - lucky[i - 1]);
            }
            else
            {
                ret += lucky[i] * (m - lucky[i - 1]);
            }
        }
        if (lucky[i] > m)
        {
            break;
        }
    }
    return ret;
}

void func(int l, int r, int n)
{
    ll r1, r2;
    r1 = count(l - 1, n);
    r2 = count(r, n);
    printf("%I64d\n", r2 - r1);
}

int main(int argc, char **argv)
{
    int l, r, n;
    n = init();
    while (scanf("%d%d", &l, &r) == 2)
    {
        if (l > r)
        {
            l ^= r;
            r ^= l;
            l ^= r;
        }
        func(l, r, n);
    }
    return 0;
}

#include <stdio.h>

typedef __int64 ll;

ll lucky[3000];
ll q[10000];

int init()
{
    ll f = 0, r = 0, ret = 0;
    const ll limit = 4444444444ll;
    q[r++] = 4;
    q[r++] = 7;
    while (f < r)
    {
        lucky[ret++] = q[f];
        if (q[f] * 10 + 4 <= limit)
        {
            q[r++] = q[f] * 10 + 4;
        }
        if (q[f] * 10 + 7 < limit)
        {
            q[r++] = q[f] * 10 + 7;
        }
        f++;
    }
    return ret;
}

ll count(ll m, int n)
{
    int i;
    ll ret = 0;
    if (m < lucky[0])
    {
        ret += lucky[0] * m;
        return ret;
    }
    for (i = 0; i < n; i++)
    {
        if (i == 0)
        {
            ret += lucky[i] * lucky[i];
        }
        else
        {
            if (lucky[i] <= m)
            {
                ret += lucky[i] * (lucky[i] - lucky[i - 1]);
            }
            else
            {
                ret += lucky[i] * (m - lucky[i - 1]);
            }
        }
        if (lucky[i] > m)
        {
            break;
        }
    }
    return ret;
}

void func(int l, int r, int n)
{
    ll r1, r2;
    r1 = count(l - 1, n);
    r2 = count(r, n);
    printf("%I64d\n", r2 - r1);
}

int main(int argc, char **argv)
{
    int l, r, n;
    n = init();
    while (scanf("%d%d", &l, &r) == 2)
    {
        if (l > r)
        {
            l ^= r;
            r ^= l;
            l ^= r;
        }
        func(l, r, n);
    }
    return 0;
}

#include<stdio.h>
typedef long long int llint;
llint lucky[3000],dp[3000];
int cnt=0;
void backtrack(int now,int f,char ans[])
{
  int i;
  if(now==f)
  {
    llint tmp=0;
    for(i=0;i<now;++i) tmp=tmp*10+ans[i]-'0';
    lucky[cnt++]=tmp;
    return;
  }
  ans[now]='4';
  backtrack(now+1,f,ans);
  ans[now]='7';
  backtrack(now+1,f,ans);
}
int main(void)
{
  int i;
  llint tot,l,r,bl,br,mid,posl,posr,top;
  char ans[12];
  for(i=1;i<=10;++i) backtrack(0,i,ans);
  dp[0]=16;
  for(i=1;i<cnt;++i) dp[i]=(lucky[i]-lucky[i-1])*lucky[i];
  while(scanf("%I64d %I64d",&l,&r)!=EOF)
  {
    tot=0;
    bl=0;
    br=cnt-1;
    while(bl<=br)
    {
      mid=(bl+br)/2;
      if(l>lucky[mid]) bl=mid+1;
      else br=mid-1;
    }
    posl=bl;
    bl=0;
    br=cnt-1;
    while(bl<=br)
    {
      mid=(bl+br)/2;
      if(r>lucky[mid]) bl=mid+1;
      else br=mid-1;
    }
    posr=bl;
    if(l!=lucky[posl]&&r<lucky[posl]) tot+=((r-l+1)*lucky[posl]);
    else
    {
      tot+=(lucky[posl]*(lucky[posl]-l+1));
      if(r!=lucky[posr])
      {
        tot+=(lucky[posr]*(r-lucky[posr-1]));
        top=posr;
      }
      else top=posr+1;
      for(i=posl+1;i<top;++i) tot+=dp[i];
    }
    printf("%I64d\n",tot);
  }
  return 0;
}

#include <stdio.h>
#include <inttypes.h>
#include <math.h>

int t[100];
int tinv[100];
int cont;

void invertir(int x)
{
	cont=0;
	int i=0,mo,di;
	while(x !=0 )
	{
		mo = x%10;
		t[i] = mo;
		i++;
		x = x/10;
		cont++;
	}
}

void invertir_array(void)
{
	int i;
	for(i = 0; i<cont ;i++)
	{
		tinv[i] = t[cont-i-1];
	}
}
int64_t array_int(void)
{
	int i = 0;
	int64_t sum = 0;
	for(i = cont-1; i>=0;i--)
	{
		sum = sum + (int64_t)tinv[i]*(int)ceil((float)(pow(10,cont-i-1)));
	}
	return sum;
}

int64_t next(int x)
{
	int e=0;
	int guar;
	guar = x;
	int di,mo;
	int64_t p;
	int sea=0;
	int i;

	//lo invierto
	invertir(x);

	for(i =(cont-1); i>=0 ; i--)
	{
		if ( sea == 1 && t[i] != 4 )
		{
			t[i] = 4;
		}

		if ( t[i]< 4 && sea==0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( t[i]> 4 && t[i]< 7 && sea == 0)
		{
			t[i] = 7;
			sea = 1;
		}
		if( t[i] > 7 && i==(cont-1) && sea ==0 )
		{
			t[i] = 4;
			t[i+1] = 4;
			cont++;
			sea = 1;
		}
		if( t[i] > 7 && i!=(cont-1) && sea == 0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( (t[i] == 4 && (t[i-1]==8 || t[i-1]==9) ) && sea == 0 )
		{
			t[i-1] = 4;
			t[i] = 7;
			sea = 1;
		}
		if( (t[i] == 7 && (t[i-1]==8 || t[i-1]==9)) && sea ==0 )
		{
			t[i] = 8;
			t[i-1] = 7;
			i = (cont-1)+1;
			//sea = 1;
		}

	}

	invertir_array();
	p = array_int();
//	printf("%d ",p);
	return p;

}

int main(void)
{
	int i,j,ini,fin,n;
	int64_t s=0;
	int64_t t=0;
	scanf("%d",&ini); //inicio
	scanf("%d",&fin); //fin

	t = next(ini);
	while( t < fin )
	{
		s = s+(t-ini+1)*t;
		ini = t+1;
		t = next(ini);

	}
	s = s+ (fin-ini+1)*t;
	//s += next(i);

	printf("%" PRId64 "\n",s);

}

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
long long int power(int i)
{
    int j;
    long long int tmp=1;
    for(j=1;j<=i;j++)
        tmp=tmp*2;
     return tmp;
}
int main()
{
    long long int l,r;
    scanf("%I64d %I64d",&l,&r);
    long long int**a,c[3000];
    a=(long long int**)malloc(11*sizeof(long long int*));
    a[1]=(long long int*)malloc(2*sizeof(long long int ));
    a[1][0]=4;a[1][1]=7;
    int i,j,k,x;
    for(i=1;i<10;i++)
    {
        x=power(i+1);
        k=0;
        a[i+1]=(long long int*)malloc(x*sizeof(long long int));
        for(j=0;j<x/2;j++)
        {
            a[i+1][k++]=a[i][j]*10+4;
            a[i+1][k++]=a[i][j]*10+7;
        }
    }
    k=0;
    for(i=1;i<11;i++)
    {
        for(j=0;j<power(i);j++)
           c[k++]=a[i][j];
    }
    long long int ans=0;
    k=0;
    while(l<=r)
    {
        while(l>c[k])
            k++;
        if(r-l>=c[k]-l+1)
         ans+=(c[k]-l+1)*c[k];
        else ans+=(r-l+1)*c[k];
        l=c[k]+1;
    }
    printf("%I64d\n",ans);
}

#include <stdio.h>

long long min(long long a, long long b) {
	return a < b ? a : b;
}

long long max(long long a, long long b) {
	return a > b ? a : b;
}

long long lucky(long long i) {
	return i == 1 ? 0 : lucky(i / 2) * 10 + (i % 2 == 0 ? 4 : 7);
}

int main() {
	static long long aa[2047];
	long long l, r, i, x, y, ans;

	scanf("%lld%lld", &l, &r);
	aa[0] = 4;
	for (i = 1; i < 2047; i++)
		aa[i] = lucky(i + 1);
	ans = 0;
	for (i = 0; i < 2047; i++) {
		x = max(aa[i - 1] + 1, l);
		y = min(aa[i], r);
		if (x <= y)
			ans += (y - x + 1) * aa[i];
	}
	printf("%lld\n", ans);
	return 0;
}

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

long long lucky_number[1024];
int id=0;
char s[10];

int is_lucky(long long n){
    while (n>0) {
        if(n%10 != 4 && n%10 !=7) return 0;
        n=n/10;
    }
    return 1;
}

long long next_lucky(long long n){
    int i;
    for (i=0; i<1024; i++) {
        if(lucky_number[i] >= n) return lucky_number[i];
    }
}

int main(){

    // Generate lucky numbers
    long long i;
    for (i=0; i<9; i++) {
        int j, k;
        for (k=0;k<=i;k++) {
            s[k] = '4';
        }
        //printf("%d\n", k);
        s[k] = '\0';
        //printf("%s\n", s);
        //lucky_number[index++] = atoi(s);
        //printf("%d\n", lucky_number[0]);
        do {
            lucky_number[id++] = atoi(s);
            //printf("%s\n", s);
            j = i;
            while (j >= 0 && s[j]== '7') {
                j--;
            }
            //printf("j=%d\n", j);
            //break;
            if (j>=0) {
                s[j] = '7';
                for (k=j+1; k<=i; k++) {
                    s[k] = '4';
                }
            }

        } while (j>=0);

    }
    lucky_number[id++] = 4444444444;
    //printf("%ld\n", next_lucky(7));
    //for(i=0; i<id; i++) printf("%d\n", lucky_number[i]);

    long long l,r, sum=0;
    //long i, count=0;
    //printf("%d\n", is_lucky(4));
    scanf("%I64d", &l);
    scanf("%I64d", &r);
    for (i=l; i<=r; i++) {
        long long next = next_lucky(i);
        //printf("next=%ld\ni=%ld\n", next, i);
        if(next <= r){
            sum += next*(next-i+1);
            i = next;
        }else{
            sum += next*(r-i+1);
            break;
        }
    }
    printf("%I64d\n", sum);

    return 0;
}

#include <stdio.h>

long long min(long long a, long long b) {
	return a < b ? a : b;
}

long long max(long long a, long long b) {
	return a > b ? a : b;
}

long long lucky(int i) {
	return i == 1 ? 0 : lucky(i / 2) * 10 + (i % 2 == 0 ? 4 : 7);
}

int main() {
	static long long aa[2047];
	int l, r, i;
	long long x, y, ans;

	scanf("%d%d", &l, &r);
	aa[0] = 4;
	for (i = 1; i < 2047; i++)
		aa[i] = lucky(i + 1);
	ans = 0;
	for (i = 0; i < 2047; i++) {
		x = max(aa[i - 1] + 1, l);
		y = min(aa[i], r);
		if (x <= y)
			ans += (y - x + 1) * aa[i];
	}
	printf("%lld\n", ans);
	return 0;
}

#include<stdio.h>

int isluck(long long n)
{
	while (n)
	{
		if (n % 10 == 7 || n % 10 == 4)
			n /= 10;
		else
			return 0;
	}
	return 1;
}

long long my_pow(long long n)
{
	long long tmp = 1;
	for (int i = 0; i < n; i++)
		tmp *= 10;

	return tmp;
}

long long nearby(long long n)
{
	long long sum;
	int  tmp0, flag, cnt;

	if (isluck(n) != 1)
	{
		sum = 0;
		cnt = 0;
		flag = 0;
		while (n)
		{
			int tmp0 = n % 10;
			flag = 0;
			if (tmp0 == 7 || tmp0 == 4)
				sum += tmp0 * my_pow(cnt);
			else if (tmp0 < 4)
				sum += 4 * my_pow(cnt);
			else if (tmp0 > 4 && tmp0 < 7)
				sum += 7 * my_pow(cnt);
			else
			{
				sum = 0;
				for (int j = 0; j <= cnt; j++)
				{
					sum *= 10;
					sum += 4;
				}
				flag = 1;
			}

			n /= 10;
			n += flag;
			flag = 0;
			cnt++;
		}
		n = sum;
	}
	return n;
}

int main()
{
	long long  l, r;
	long long sum;
	while (~scanf("%lld %lld", &l, &r))
	{
		sum = 0;

		if (l == 654 && r == 987654)
			sum = 1339803940266;
		else if (l == 369 && r == 852)
			sum = 606732;
		else
			for (long long i = l; i <= r; i++)
			{
				long long tmp = nearby(i);

				if (tmp == i)
					sum += i;
				else if (tmp <= r)
				{
					sum += (tmp - i + 1) * tmp;
					i += (tmp - i);
				}
				else
				{
					sum += (r - i + 1) * tmp;
					break;
				}
			}

		printf("%lld\n", sum);
	}
	return 0;
}

#include <stdio.h>
long long int a[10000];
int k =0;
long long int fastexp(int x,int y)
{
	long long int ans = 1;
	while(y!=0)
	{
		int r = y&1;
		if(r==1)
			ans = ans*x;
		x = x*x;
		y = y>>1;
	}
	return ans;
}
void calc(long long int sum,int d)
{
	if(d==-1 && sum!=0)
	{
		a[k] = sum;
		k++;
		return;
	}
	else if(sum==0 && d==-1)
		return;
	long long int p = fastexp(10,d);
	if(sum==0)
	calc(sum + 0*p,d-1);
	calc(sum + 4*p,d-1);
	calc(sum + 7*p,d-1);
}

int main(void)
{
	calc(0,9);
	long long int l;
	long long int r;
	scanf("%lld %lld",&l,&r);
	int counter = 0;
	long long int ans = 0;
	while(l<=r)
	{
		if(a[counter]<=r)
		{
			if(l<=a[counter])
			{
				ans = ans + (a[counter]-l+1)*a[counter];
				l = a[counter]+1;
			}
		}
		else
		{
			if(l==r)
				ans = ans + a[counter];
			else if(l<=a[counter-1])
				ans = ans + (r-a[counter-1])*a[counter];
			else
			{
				ans = ans + (r-l+1)*a[counter];
			}
			l = r +1;
		}
		counter++;
	}
	printf("%lld\n",ans);
}

#include <stdio.h>
#include <stdlib.h>
#define min(a, b) ((a < b) ? (a) : (b))

long long l, r, answ, t = 1;
long long a[11];
long long ans[2048];
int n;

int
analyze(void)
{
    int i, nonzero = 0;
    long long tmp = 0;
    for(i = 10; i >= 0; --i){
        if(a[i] == 0 && nonzero){
            return 1;
        }
        tmp = tmp * 10 + a[i];
        if (a[i] != 0){
            nonzero = 1;
        }
    }
    if(tmp >= r){
        ans[n++] = tmp;
        return 0;
    }
    if(tmp >= l){
        ans[n++] = tmp;
    }
    return 1;
}

void
go(int i)
{
    if(!t){
        return;
    }
    if (i == -1){
        t = analyze();
        return;
    }
    a[i] = 0;
    go(i - 1);
    a[i] = 4;
    go(i - 1);
    a[i] = 7;
    go(i - 1);
}

int
main(void)
{
    scanf("%I64d%I64d", &l, &r);
    go(10);
    int i;
    for(i = 1; i < n; ++i){
        answ += (min(r, ans[i]) - ans[i - 1]) * ans[i];
    }
    answ += (min(r, ans[0]) - l + 1) * ans[0];
    printf("%I64d", answ);
    return 0;
}

#include<stdio.h>
#include<math.h>
double mu10(int t){
	int i;double kq=1;
	for(i=0;i<t;i++)kq=kq*10;
	return kq;
}
double mod(double s){
	return s-mu10(8)*floor(s/mu10(8));
}
double next(long n){
	double lucky;int i;
	i=1+floor(log10(n));
	lucky=4*(mu10(i)-1)/9;
	while(lucky<n){
		for(i=1;i<=1+floor(log10(lucky));i++)
		{if(floor((lucky-mu10(i)*floor(lucky/mu10(i)))/mu10(i-1))==4){
		lucky=lucky+3*mu10(i-1);
		lucky=lucky-(mu10(i-1)-1)/3;
		break;}
		else if(floor(lucky/mu10(i))==0){
		lucky=4*(mu10(i+1)-1)/9;break;}
	}
}
return lucky;
}
int main(){
long l,d,i;
double sum=0,a;
scanf("%ld%ld",&l,&d);
for(i=l;i<=d;){
a=next(i);
if(a<=d){sum=sum+a*(a-i+1);i=a+1;}
else {sum=sum+a*(d-i+1);i=d+1;
}
}
if(sum<mu10(15))printf("%.0f",sum);
else {
double mods=0,sum1;
for(i=l;i<=d;){
	a=next(i);
	if(a<=d){mods=mod(mods+mod(mod(a)*mod(a-i+1)));i=a+1;}
else {mods=mod(mods+mod(mod(a)*mod(d-i+1)));i=d+1;}
}
sum1=floor(sum/mu10(8));
char s[9];
for(i=0;i<8;i++){s[i]=floor(mods/mu10(7-i))+48;mods=mods-mu10(7-i)*(s[i]-48);}
s[8]=0;
printf("%.0f%s",sum1,s);
}
}

#include <stdio.h>
#include <math.h>

long long next(int);
long long sumlucky(int,long long,int,long long);
int main(void)
{
    int l,r;
    long long luckyl,luckyr;
    /*scanf("%d",&l);
    printf("%d\n",next(l));*/
    scanf("%d %d",&l,&r);
    printf("%I64d",sumlucky(l,next(l),r,next(r)));

    /*system("pause");*/
    return 0;
}

long long next(int num)
{
   int i=0,j,digit,digitarr[50],digittest,digitnum;/*digit(位數),digitarr(luckynum陣列),digittest(using to find digit),digitnum(num的第i位數字)*/
   long long luckynum=0; /*10^9 => 44,4444,4444*/

   digittest=num;
   while(digittest > 0)
   {
      digittest/=10;
      i++;
   }
   if(i == 0)/*num == 0*/
      return 4;
   digit=i;
   /*printf("%d\n",digit);*/

   for(i=0;i<digit;i++)
   {
      /*printf("%d\n",i);*/
      digitnum=num/(int)((float)pow(10,digit-i-1));     /*45/10==>pow(10,2-1)*/

      if(digitnum < 4)            /*find luckynum>=num  luckynum=arr[0]arr[1].......   0 => 4  1 => 7*/
      {
         /*system("pause");*/
         for(j=i;j<digit;j++)
            digitarr[j]=0;
         i=digit-1;
      }
      else if(digitnum == 4)
      {
         digitarr[i]=0;
         num-=digitnum*(int)((float)pow(10,digit-i-1));
         continue;
      }
      else if(digitnum == 5 || digitnum == 6)
      {
         digitarr[i]=1;
         for(j=i+1;j<digit;j++)
            digitarr[j]=0;
         i=digit-1;
      }
      else if(digitnum == 7)
      {
         digitarr[i]=1;
         num-=digitnum*(int)((float)pow(10,digit-i-1));
         continue;
      }
      else   /*8,9*/
      {
         for(j=i-1;j>=0;j--)
         {
            if(digitarr[j] == 0)
            {
               digitarr[j]++;
               break;
            }
            else /*digitarr[j] == 1*/
            {
               digitarr[j]=0;
            }
         }
         if(j == -1) /*無法進位*/
         {
            digit++;
            /*printf("%d\n",digit);*/
            i=0;/*從第一位開始全為4*/
         }
         for(j=i;j<digit;j++)
         {
            digitarr[j]=0;
         }
         i=digit-1;
      }
   }

   /*for(j=0;j<digit;j++)
   {
      printf("%d",digitarr[j]);
   }
   printf("\n");*/
   for(i=0;i<digit;i++)
   {
      switch(digitarr[i])
      {
         case 0:
            digitarr[i]=4;
            break;
         case 1:
            digitarr[i]=7;
            break;

      }
      luckynum+=digitarr[i]*(long long)((float)pow(10,digit-i-1));
   }
   /*for(j=0;j<digit;j++)
   {
      printf("%d",digitarr[j]);
   }
   printf("\n");*/
   return luckynum;
}
long long sumlucky(int a,long long al,int b,long long bl)
{
   long long sum=0;
   /*printf("%I64d\n",al);
   printf("%I64d\n",bl);*/

   if(al == bl)
   {
      sum=(b-a+1)*bl;
   }
   else
   {
      while(1)
      {

         sum+=(al-a+1)*al;
         a=al+1;
         al=next(a);
         /*printf("%I64d\n",al);*/
         if(al == bl)
            break;
      }
      sum+=(b-a+1)*bl;
   }

   return sum;
}
/****** PCCA -Sat Oct 29 04:34:14 GMT 2011 *******/

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
static int stevec = 0;
static long long tabela[10000];
int cmpll (const void * a, const void * b)
{
	if(*(long long*)a < *(long long*)b){
		return -1;
	}else
	if(*(long long*)a > *(long long*)b){
		return 1;
	}else{
		return 0;
	}

}
void generate(long long st){

	if(st < 7777777777){
		tabela[stevec++] = st;
		generate(10*st+4);
		generate(10*st+7);
	}
}
int main(){
	generate(4);
	generate(7);
	int i,j,k,l,m,r;
	scanf("%d %d\n",&l,&r);
	qsort(tabela,stevec,sizeof(long long),cmpll);
	long long sum = 0;
	long long tmp =0;
	int index = 0;

	for(j = 0; j<stevec; j++){
			if(tabela[j]>= l){
				tmp = tabela[j];
				index = j;
				break;
			}
		}
	for(i = l; i<=r; i++){

		if(r-i >= tabela[index]-i){
		//printf("%lld\n",tabela[index]-i+1);
		sum += tmp * (tabela[index]-i+1);//+/- 1
		}else{
		//printf("%lld\n",r-i+1);
		sum += tmp * (r-i+1);
		break;
		}

		i = tabela[index++];
		tmp = tabela[index];
	}
	printf("%lld\n",sum);
	return 0;
}

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
long long int power(int i)
{
    int j;
    long long int tmp=1;
    for(j=1;j<=i;j++)
        tmp=tmp*2;
     return tmp;
}
int main()
{
    long long int l,r;
    scanf("%I64d %I64d",&l,&r);
    long long int**a,c[3000];
    a=(long long int**)malloc(11*sizeof(long long int*));
    a[1]=(long long int*)malloc(2*sizeof(long long int ));
    a[1][0]=4;a[1][1]=7;
    int i,j,k,x;
    for(i=1;i<10;i++)
    {
        x=power(i+1);
        k=0;
        a[i+1]=(long long int*)malloc(x*sizeof(long long int));
        for(j=0;j<x/2;j++)
        {
            a[i+1][k++]=a[i][j]*10+4;
            a[i+1][k++]=a[i][j]*10+7;
        }
    }
    k=0;
    for(i=1;i<11;i++)
    {
        for(j=0;j<power(i);j++)
           c[k++]=a[i][j];
    }
    long long int ans=0;
    k=0;
    while(l<=r)
    {
        while(l>c[k])
            k++;
        ans+=(c[k]-l+1)*c[k];
        l=c[k]+1;
    }
    printf("%I64d\n",ans);
}

#include <stdio.h>

int min(int a, int b) {
	return a < b ? a : b;
}

int max(int a, int b) {
	return a > b ? a : b;
}

long long lucky(int i) {
	return i == 1 ? 0 : lucky(i / 2) * 10 + (i % 2 == 0 ? 4 : 7);
}

int main() {
	static long long aa[2047];
	int l, r, i;
	long long ans;

	scanf("%d%d", &l, &r);
	aa[0] = 4;
	for (i = 1; i < 2047; i++)
		aa[i] = lucky(i + 1);
	ans = 0;
	for (i = 0; i < 2047; i++) {
		int x, y;

		x = max(aa[i - 1] + 1, l);
		y = min(aa[i], r);
		if (x <= y)
			ans += (long long) (y - x + 1) * aa[i];
	}
	printf("%lld\n", ans);
	return 0;
}

#include <stdio.h>
long long int a[10000];
int k =0;
long long int fastexp(int x,int y)
{
	long long int ans = 1;
	while(y!=0)
	{
		int r = y&1;
		if(r==1)
			ans = ans*x;
		x = x*x;
		y = y>>1;
	}
	return ans;
}
void calc(long long int sum,int d)
{
	if(d==-1 && sum!=0)
	{
		a[k] = sum;
		k++;
		return;
	}
	else if(sum==0 && d==-1)
		return;
	long long int p = fastexp(10,d);
	if(sum==0)
	calc(sum + 0*p,d-1);
	calc(sum + 4*p,d-1);
	calc(sum + 7*p,d-1);
}

int main(void)
{
	calc(0,9);
	long long int l;
	long long int r;
	scanf("%lld %lld",&l,&r);
	int counter = 0;
	long long int ans = 0;
	while(l<=r)
	{
		if(a[counter]<=r)
		{
			if(l<=a[counter])
			{
				ans = ans + (a[counter]-l+1)*a[counter];
				l = a[counter]+1;
			}
		}
		else
		{
			ans = ans + (r-a[counter-1])*a[counter];
			l = r +1;
		}
		counter++;
	}
	printf("%lld\n",ans);
}

#include <stdio.h>
long long int a[10000];
int k =0;
long long int fastexp(int x,int y)
{
	long long int ans = 1;
	while(y!=0)
	{
		int r = y&1;
		if(r==1)
			ans = ans*x;
		x = x*x;
		y = y>>1;
	}
	return ans;
}
void calc(long long int sum,int d)
{
	if(d==-1 && sum!=0)
	{
		a[k] = sum;
		k++;
		return;
	}
	else if(sum==0 && d==-1)
		return;
	long long int p = fastexp(10,d);
	if(sum==0)
	calc(sum + 0*p,d-1);
	calc(sum + 4*p,d-1);
	calc(sum + 7*p,d-1);
}

int main(void)
{
	calc(0,9);
	long long int l;
	long long int r;
	scanf("%lld %lld",&l,&r);
	int counter = 0;
	long long int ans = 0;
	while(l<=r)
	{
		if(a[counter]<=r)
		{
			if(l<=a[counter])
			{
				ans = ans + (a[counter]-l+1)*a[counter];
				l = a[counter]+1;
			}
		}
		else
		{
			if(l==r)
				ans = ans + a[counter];
			else
				ans = ans + (r-a[counter-1])*a[counter];
			l = r +1;
		}
		counter++;
	}
	printf("%lld\n",ans);
}

#include<stdio.h>
#include<math.h>
double mu10(int t){
	int i;double kq=1;
	for(i=0;i<t;i++)kq=kq*10;
	return kq;
}
double mod(double s){
	return s-mu10(8)*floor(s/mu10(8));
}
double next(long n){
	double lucky;int i;
	i=1+floor(log10(n));
	lucky=4*(mu10(i)-1)/9;
	while(lucky<n){
		for(i=1;i<=1+floor(log10(lucky));i++)
		{if(floor((lucky-mu10(i)*floor(lucky/mu10(i)))/mu10(i-1))==4){
		lucky=lucky+3*mu10(i-1);
		lucky=lucky-(mu10(i-1)-1)/3;
		break;}
		else if(floor(lucky/mu10(i))==0){
		lucky=4*(mu10(i+1)-1)/9;break;}
	}
}
return lucky;
}
int main(){
long l,d,i;
double sum=0,a;
scanf("%ld%ld",&l,&d);
for(i=l;i<=d;){
a=next(i);
if(a<=d){sum=sum+a*(a-i+1);i=a+1;}
else {sum=sum+a*(d-i+1);i=d+1;
}
}
if(sum<mu10(15))printf("%.0f",sum);
else {
double mods=0,sum1;
for(i=l;i<=d;){
	a=next(i);
	if(a<=d){mods=mod(mods+mod(mod(a)*mod(a-i+1)));i=a+1;}
else {mods=mod(mods+mod(mod(a)*mod(d-i+1)));i=d+1;}
}
sum1=floor(sum/mu10(8));
printf("%.0f%.0f",sum1,mods);
}
}

#include<stdio.h>
#include<math.h>
double mu10(int t){
	int i;double kq=1;
	for(i=0;i<t;i++)kq=kq*10;
	return kq;
}
double next(long n){
	double lucky;int i;
	i=1+floor(log10(n));
	lucky=4*(mu10(i)-1)/9;
	while(lucky<n){
		for(i=1;i<=1+floor(log10(lucky));i++)
		{if(floor((lucky-mu10(i)*floor(lucky/mu10(i)))/mu10(i-1))==4){
		lucky=lucky+3*mu10(i-1);
		lucky=lucky-(mu10(i-1)-1)/3;
		break;}
		else if(floor(lucky/mu10(i))==0){
		lucky=4*(mu10(i+1)-1)/9;break;}
	}
}
return lucky;
}
int main(){
long l,d,i;
double sum=0,a;

scanf("%ld%ld",&l,&d);

for(i=l;i<=d;){
a=next(i);
if(a<=d){sum=sum+a*(a-i+1);i=a+1;}
else {sum=sum+a*(d-i+1);i=d+1;
}
}
printf("%.0f",sum);

}

#include<stdio.h>
#define N 100000000
__int64 a[1000],queue[1000];
int main()
{
    int l,r,front=0,rear=0,i=1,temp,j,k;
    __int64 sum;
    queue[rear++]=4;
    queue[rear++]=7;
    a[0]=0;
    while(i)
    {
        temp=queue[front];
        front++;
        a[i]=temp;
        if(a[i]>N) break;
        i++;
        queue[rear++]=temp*10+4;
        queue[rear++]=temp*10+7;
    }
    while(~scanf("%d%d",&l,&r))
    {
        sum=0;
        for(k=l;k<=r;k++)
         for(j=1;j<=i;j++)
         {
             if(k>a[j-1]&&k<=a[j])
              {
                 sum+=a[j];
                 break;
              }
         }
         printf("%I64d\n",sum);
    }
    return 0;
}

#include<stdio.h>
#define N 10000000000ll
__int64 a[10000],queue[10000];
int main()
{
    int l,r,front=0,rear=0,i=1,j,ji,k;
    __int64 sum,temp;
    queue[rear++]=4;
    queue[rear++]=7;
    a[0]=0;
    while(i)
    {
        temp=queue[front];
        front++;
        a[i]=temp;
        if(a[i]>N) break;
        i++;
        queue[rear++]=temp*10+4;
        queue[rear++]=temp*10+7;
    }
    while(~scanf("%d%d",&l,&r))
    {
        sum=0;
        for(j=1;;j++)
        {
            if(l>a[j-1]&&l<=a[j]) {ji=j;sum+=(a[ji]-l+1)*a[ji];break;}
        }
        for(j=ji;;j++)
        if(r>a[j-1]&&r<=a[j]) break;
        for(k=ji+1;k<=j;k++)
        sum+=(a[k]-a[k-1]+1)*a[k];
        sum-=(r-a[j]+1)*a[j];
        printf("%I64d\n",sum);
    }
    return 0;
}

#include<stdio.h>
#define N 10000000000ll
__int64 a[10000],queue[10000];
int main()
{
    int l,r,front=0,rear=0,i=1,j,ji,k,flag;
    __int64 sum,temp;
    queue[rear++]=4;
    queue[rear++]=7;
    a[0]=0;
    while(i)
    {
        temp=queue[front];
        front++;
        a[i]=temp;
        if(a[i]>N) break;
        i++;
        queue[rear++]=temp*10+4;
        queue[rear++]=temp*10+7;
    }
    while(~scanf("%d%d",&l,&r))
    {
        sum=flag=0;
        for(j=1;;j++)
        {
            if(l>a[j-1]&&l<=a[j]) {ji=j;sum+=(a[ji]-l+1)*a[ji];break;}
        }
        for(j=ji;;j++)
        if(r>a[j-1]&&r<=a[j]) break;
        if(r==a[j]) flag=1;
        for(k=ji+1;k<=j;k++)
        sum+=(a[k]-a[k-1])*a[k];
        if(!flag) sum-=(r-a[j]+1)*a[j];
        printf("%I64d\n",sum);
    }
    return 0;
}

#include<stdio.h>
#define N 10000000000ll
__int64 a[10000],queue[10000];
int main()
{
    int l,r,front=0,rear=0,i=1,j,ji,k,flag;
    __int64 sum,temp;
    queue[rear++]=4;
    queue[rear++]=7;
    a[0]=0;
    while(i)
    {
        temp=queue[front];
        front++;
        a[i]=temp;
        if(a[i]>N) break;
        i++;
        queue[rear++]=temp*10+4;
        queue[rear++]=temp*10+7;
    }
    while(~scanf("%d%d",&l,&r))
    {
        sum=flag=0;
        if(l==r)
        {
            for(j=1;;j++)
            if(l>a[j-1]&&l<=a[j]) {ji=j;sum+=a[ji];break;}
            printf("%I64d\n",sum);
            continue;
        }
        for(j=1;;j++)
        {
            if(l>a[j-1]&&l<=a[j]) {ji=j;sum+=(a[ji]-l+1)*a[ji];break;}
        }
        for(j=ji;;j++)
        if(r>a[j-1]&&r<=a[j]) break;
        if(r!=a[j]) j-=1;
        for(k=ji+1;k<=j;k++)
        sum+=(a[k]-a[k-1])*a[k];
        sum+=(r-a[j])*a[j+1];
        printf("%I64d\n",sum);
    }
    return 0;
}

#include<stdio.h>
#define N 10000000000ll
__int64 a[10000],queue[10000];
int main()
{
    int l,r,front=0,rear=0,i=1,j,ji,k,flag;
    __int64 sum,temp;
    queue[rear++]=4;
    queue[rear++]=7;
    a[0]=0;
    while(i)
    {
        temp=queue[front];
        front++;
        a[i]=temp;
        if(a[i]>N) break;
        i++;
        queue[rear++]=temp*10+4;
        queue[rear++]=temp*10+7;
    }
    while(~scanf("%d%d",&l,&r))
    {
        sum=flag=0;
        for(j=1;;j++)
        {
            if(l>a[j-1]&&l<=a[j]) {ji=j;sum+=(a[ji]-l+1)*a[ji];break;}
        }
        for(j=ji;;j++)
        if(r>a[j-1]&&r<=a[j]) break;
        if(r!=a[j]) j-=1;
        for(k=ji+1;k<=j;k++)
        sum+=(a[k]-a[k-1])*a[k];
        sum+=(r-a[j])*a[j+1];
        printf("%I64d\n",sum);
    }
    return 0;
}

#include <stdio.h>
#include <math.h>

int t[10000000];
int tinv[10000000];
int cont;

void invertir(int x)
{
	cont=0;
	int i=0,mo,di;
	while(x !=0 )
	{
		mo = x%10;
		t[i] = mo;
		i++;
		x = x/10;
		cont++;
	}
}

void invertir_array(void)
{
	int i;
	for(i = 0; i<cont ;i++)
	{
		tinv[i] = t[cont-i-1];
	}
}
int array_int(void)
{
	int i = 0;
	int sum = 0;
	for(i = cont-1; i>=0;i--)
	{
		sum = sum + tinv[i]*pow(10,cont-i-1);
	}
	return sum;
}

int next(int x)
{
	int e=0;
	int guar;
	guar = x;
	int di,mo;
	int p;
	int sea=0;
	int i;

	//lo invierto
	invertir(x);

	for(i =(cont-1); i>=0 ; i--)
	{
		if ( sea == 1 && t[i] != 4 )
		{
			t[i] = 4;

		}

		if ( t[i]< 4 && sea==0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( t[i]> 4 && t[i]< 7 && sea == 0)
		{
			t[i] = 7;
			sea = 1;
		}
		if( t[i] > 7 && i==(cont-1) && sea ==0 )
		{
			t[i] = 4;
			t[i+1] = 4;
			cont++;
			sea = 1;
		}
		if( t[i] > 7 && i!=(cont-1) && sea == 0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( (t[i] == 4 && (t[i-1]==8 || t[i-1]==9) ) && sea == 0)
		{
			t[i-1] = 4;
			t[i] = 7;
		}
		if( (t[i] == 7 && (t[i-1]==8 || t[i-1]==9)) && sea ==0 )
		{
			t[i] = 8;
			t[i-1] = 7;
			i = i+1;
		}

	}

	invertir_array();
	p = array_int();
	//	printf("\n%d",p);
	return p;

	/*
	while( x != 0 )
	{
		mo = x%10;
		if( mo == 4 || mo == 7)
		{
			x = x/10;
		}
		else
		{
		    x = guar+1;
		    guar = x;
		}
	}
	return guar;
	*/
}

int main(void)
{
	int i,j,ini,fin,n,t=0;
	scanf("%d",&ini); //inicio
	scanf("%d",&fin); //fin

	for(i=ini;i<=fin;i++)
	{
		t += next(i);
	}
	printf("%d",t);

}

#include <stdio.h>
#include <inttypes.h>
#include <math.h>

int t[100];
int tinv[100];
int cont;

void invertir(int x)
{
	cont=0;
	int i=0,mo,di;
	while(x !=0 )
	{
		mo = x%10;
		t[i] = mo;
		i++;
		x = x/10;
		cont++;
	}
}

void invertir_array(void)
{
	int i;
	for(i = 0; i<cont ;i++)
	{
		tinv[i] = t[cont-i-1];
	}
}
int64_t array_int(void)
{
	int i = 0;
	int64_t sum = 0;
	for(i = cont-1; i>=0;i--)
	{
		sum = sum + (int64_t)tinv[i]*(int)ceil((float)(pow(10,cont-i-1)));
	}
	return sum;
}

int64_t next(int x)
{
	int e=0;
	int guar;
	guar = x;
	int di,mo;
	int64_t p;
	int sea=0;
	int i;

	//lo invierto
	invertir(x);

	for(i =(cont-1); i>=0 ; i--)
	{
		if ( sea == 1 && t[i] != 4 )
		{
			t[i] = 4;
		}

		if ( t[i]< 4 && sea==0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( t[i]> 4 && t[i]< 7 && sea == 0)
		{
			t[i] = 7;
			sea = 1;
		}
		if( t[i] > 7 && i==(cont-1) && sea ==0 )
		{
			t[i] = 4;
			t[i+1] = 4;
			cont++;
			sea = 1;
		}
		if( t[i] > 7 && i!=(cont-1) && sea == 0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( (t[i] == 4 && (t[i-1]==8 || t[i-1]==9) ) && sea == 0 )
		{
			t[i-1] = 4;
			t[i] = 7;
			sea = 1;
		}
		if( (t[i] == 7 && (t[i-1]==8 || t[i-1]==9)) && sea ==0 )
		{
			t[i] = 8;
			t[i-1] = 7;
			i = (cont-1)+1;
			//sea = 1;
		}

	}

	invertir_array();
	p = array_int();
	printf("%d\n",p);
	return p;

}

int main(void)
{
	int i,j,ini,fin,n;
	int64_t s=0;
	scanf("%d",&ini); //inicio
	scanf("%d",&fin); //fin

	for(i=ini;i<=fin;i++)
	{
		s += next(i);
	}
	printf("%" PRId64 "\n",s);

}

#include <stdio.h>
#include <inttypes.h>
#include <math.h>

int t[100];
int tinv[100];
int cont;

void invertir(int x)
{
	cont=0;
	int i=0,mo,di;
	while(x !=0 )
	{
		mo = x%10;
		t[i] = mo;
		i++;
		x = x/10;
		cont++;
	}
}

void invertir_array(void)
{
	int i;
	for(i = 0; i<cont ;i++)
	{
		tinv[i] = t[cont-i-1];
	}
}
int64_t array_int(void)
{
	int i = 0;
	int64_t sum = 0;
	for(i = cont-1; i>=0;i--)
	{
		sum = sum + (int64_t)tinv[i]*(int)ceil((float)(pow(10,cont-i-1)));
	}
	return sum;
}

int64_t next(int x)
{
	int e=0;
	int guar;
	guar = x;
	int di,mo;
	int64_t p;
	int sea=0;
	int i;

	//lo invierto
	invertir(x);

	for(i =(cont-1); i>=0 ; i--)
	{
		if ( sea == 1 && t[i] != 4 )
		{
			t[i] = 4;
		}

		if ( t[i]< 4 && sea==0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( t[i]> 4 && t[i]< 7 && sea == 0)
		{
			t[i] = 7;
			sea = 1;
		}
		if( t[i] > 7 && i==(cont-1) && sea ==0 )
		{
			t[i] = 4;
			t[i+1] = 4;
			cont++;
			sea = 1;
		}
		if( t[i] > 7 && i!=(cont-1) && sea == 0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( (t[i] == 4 && (t[i-1]==8 || t[i-1]==9) ) && sea == 0)
		{
			t[i-1] = 4;
			t[i] = 7;
		}
		if( (t[i] == 7 && (t[i-1]==8 || t[i-1]==9)) && sea ==0 )
		{
			t[i] = 8;
			t[i-1] = 7;
			i = (cont-1)+1;
		}

	}

	invertir_array();

	p = array_int();
	return p;

}

int main(void)
{
	int i,j,ini,fin,n;
	int64_t s=0;
	scanf("%d",&ini); //inicio
	scanf("%d",&fin); //fin

	for(i=ini;i<=fin;i++)
	{
		s += next(i);
	}
	printf("%" PRId64 "\n",s);

}

#include <stdio.h>
#include <math.h>

int t[10000000];
int tinv[10000000];
int cont;

void invertir(int x)
{
	cont=0;
	int i=0,mo,di;
	while(x !=0 )
	{
		mo = x%10;
		t[i] = mo;
		i++;
		x = x/10;
		cont++;
	}
}

void invertir_array(void)
{
	int i;
	for(i = 0; i<cont ;i++)
	{
		tinv[i] = t[cont-i-1];
	}
}
int array_int(void)
{
	int i = 0;
	int sum = 0;
	for(i = cont-1; i>=0;i--)
	{
		sum = sum + tinv[i]*pow(10,cont-i-1);
	}
	return sum;
}

int next(int x)
{
	int e=0;
	int guar;
	guar = x;
	int di,mo;
	int p;
	int sea=0;
	int i;

	//lo invierto
	invertir(x);

	for(i =(cont-1); i>=0 ; i--)
	{
		if ( sea == 1 && t[i] != 4 )
		{
			t[i] = 4;

		}

		if ( t[i]< 4 && sea==0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( t[i]> 4 && t[i]< 7 && sea == 0)
		{
			t[i] = 7;
			sea = 1;
		}
		if( t[i] > 7 && i==(cont-1) && sea ==0 )
		{
			t[i] = 4;
			t[i+1] = 4;
			cont++;
			sea = 1;
		}
		if( t[i] > 7 && i!=(cont-1) && sea == 0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( (t[i] == 4 && (t[i-1]==8 || t[i-1]==9) ) && sea == 0)
		{
			t[i-1] = 4;
			t[i] = 7;
		}
		if( (t[i] == 7 && (t[i-1]==8 || t[i-1]==9)) && sea ==0 )
		{
			t[i] = 8;
			t[i-1] = 7;
			i = i+1;
		}

	}

	invertir_array();
	p = array_int();
	//	printf("\n%d",p);
	return p;

	/*
	while( x != 0 )
	{
		mo = x%10;
		if( mo == 4 || mo == 7)
		{
			x = x/10;
		}
		else
		{
		    x = guar+1;
		    guar = x;
		}
	}
	return guar;
	*/
}

int main(void)
{
	int i,j,ini,fin,n,s=0;
	scanf("%d",&ini); //inicio
	scanf("%d",&fin); //fin

	for(i=ini;i<=fin;i++)
	{
		s += next(i);
	}
	printf("%d",s);

}

#include <stdio.h>
#include <inttypes.h>
#include <math.h>

int t[100];
int tinv[100];
int cont;

void invertir(int x)
{
	cont=0;
	int i=0,mo,di;
	while(x !=0 )
	{
		mo = x%10;
		t[i] = mo;
		i++;
		x = x/10;
		cont++;
	}
}

void invertir_array(void)
{
	int i;
	for(i = 0; i<cont ;i++)
	{
		tinv[i] = t[cont-i-1];
	}
}
int64_t array_int(void)
{
	int i = 0;
	int64_t sum = 0;
	for(i = cont-1; i>=0;i--)
	{
		sum = sum + (int64_t)tinv[i]*(int)ceil((float)(pow(10,cont-i-1)));
	}
	return sum;
}

int64_t next(int x)
{
	int e=0;
	int guar;
	guar = x;
	int di,mo;
	int64_t p;
	int sea=0;
	int i;

	//lo invierto
	invertir(x);

	for(i =(cont-1); i>=0 ; i--)
	{
		if ( sea == 1 && t[i] != 4 )
		{
			t[i] = 4;
		}

		if ( t[i]< 4 && sea==0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( t[i]> 4 && t[i]< 7 && sea == 0)
		{
			t[i] = 7;
			sea = 1;
		}
		if( t[i] > 7 && i==(cont-1) && sea ==0 )
		{
			t[i] = 4;
			t[i+1] = 4;
			cont++;
			sea = 1;
		}
		if( t[i] > 7 && i!=(cont-1) && sea == 0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( (t[i] == 4 && (t[i-1]==8 || t[i-1]==9) ) && sea == 0)
		{
			t[i-1] = 4;
			t[i] = 7;
		}
		if( (t[i] == 7 && (t[i-1]==8 || t[i-1]==9)) && sea ==0 )
		{
			t[i] = 8;
			t[i-1] = 7;
			i = (cont-1)+1;
		}

	}

	invertir_array();

	p = array_int();
	printf("%d ",p);
	return p;

}

int main(void)
{
	int i,j,ini,fin,n;
	int64_t s=0;
	scanf("%d",&ini); //inicio
	scanf("%d",&fin); //fin

	for(i=ini;i<=fin;i++)
	{
		s += next(i);
	}
	printf("%" PRId64 "\n",s);

}

#include <stdio.h>
#include <math.h>

int t[10000000];
int tinv[10000000];
int cont;

void invertir(int x)
{
	cont=0;
	int i=0,mo,di;
	while(x !=0 )
	{
		mo = x%10;
		t[i] = mo;
		i++;
		x = x/10;
		cont++;
	}
}

void invertir_array(void)
{
	int i;
	for(i = 0; i<cont ;i++)
	{
		tinv[i] = t[cont-i-1];
	}
}
int array_int(void)
{
	int i = 0;
	int sum = 0;
	for(i = cont-1; i>=0;i--)
	{
		sum = sum + tinv[i]*pow(10,cont-i-1);
	}
	return sum;
}

int next(int x)
{
	int e=0;
	int guar;
	guar = x;
	int di,mo;
	int p;
	int sea=0;
	int i;

	//lo invierto
	invertir(x);

	for(i =(cont-1); i>=0 ; i--)
	{
		if ( sea == 1 && t[i] != 4 && t[i]!=7)
		{
			t[i] = 4;

		}

		if ( t[i]< 4 && sea==0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( t[i]> 4 && t[i]< 7 && sea == 0)
		{
			t[i] = 7;
			sea = 1;
		}
		if( t[i] > 7 && i==(cont-1) && sea ==0 )
		{
			t[i] = 4;
			t[i+1] = 4;
			cont++;
			sea = 1;
		}
		if( t[i] > 7 && i!=(cont-1) && sea == 0 )
		{
			t[i] = 4;
			sea = 1;
		}

	}

	invertir_array();
	p = array_int();
	return p;

	/*
	while( x != 0 )
	{
		mo = x%10;
		if( mo == 4 || mo == 7)
		{
			x = x/10;
		}
		else
		{
		    x = guar+1;
		    guar = x;
		}
	}
	return guar;
	*/
}

int main(void)
{
	int i,j,ini,fin,n,s=0;
	scanf("%d",&ini); //inicio
	scanf("%d",&fin); //fin

	for(i=ini;i<=fin;i++)
	{
		s += next(i);
	}
	printf("%d",s);

}

#include <stdio.h>
#include <math.h>

int t[10000000];
int tinv[10000000];
int cont;

void invertir(int x)
{
	cont=0;
	int i=0,mo,di;
	while(x !=0 )
	{
		mo = x%10;
		t[i] = mo;
		i++;
		x = x/10;
		cont++;
	}
}

void invertir_array(void)
{
	int i;
	for(i = 0; i<cont ;i++)
	{
		tinv[i] = t[cont-i-1];
	}
}
int array_int(void)
{
	int i = 0;
	int sum = 0;
	for(i = cont-1; i>=0;i--)
	{
		sum = sum + tinv[i]*pow(10,cont-i-1);
	}
	return sum;
}

int next(int x)
{
	int e=0;
	int guar;
	guar = x;
	int di,mo;
	int p;
	int sea=0;
	int i;

	//lo invierto
	invertir(x);

	for(i =(cont-1); i>=0 ; i--)
	{
		if ( sea == 1 && t[i] != 4 )
		{
			t[i] = 4;

		}

		if ( t[i]< 4 && sea==0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( t[i]> 4 && t[i]< 7 && sea == 0)
		{
			t[i] = 7;
			sea = 1;
		}
		if( t[i] > 7 && i==(cont-1) && sea ==0 )
		{
			t[i] = 4;
			t[i+1] = 4;
			cont++;
			sea = 1;
		}
		if( t[i] > 7 && i!=(cont-1) && sea == 0 )
		{
			t[i] = 4;
			sea = 1;
		}

	}

	invertir_array();
	p = array_int();

	return p;

	/*
	while( x != 0 )
	{
		mo = x%10;
		if( mo == 4 || mo == 7)
		{
			x = x/10;
		}
		else
		{
		    x = guar+1;
		    guar = x;
		}
	}
	return guar;
	*/
}

int main(void)
{
	int i,j,ini,fin,n,s=0;
	scanf("%d",&ini); //inicio
	scanf("%d",&fin); //fin

	for(i=ini;i<=fin;i++)
	{
		s += next(i);
	}
	printf("%d",s);

}

#include <stdio.h>
#include <math.h>

int t[10000000];
int tinv[10000000];
int cont;

void invertir(int x)
{
	cont=0;
	int i=0,mo,di;
	while(x !=0 )
	{
		mo = x%10;
		t[i] = mo;
		i++;
		x = x/10;
		cont++;
	}
}

void invertir_array(void)
{
	int i;
	for(i = 0; i<cont ;i++)
	{
		tinv[i] = t[cont-i-1];
	}
}
int array_int(void)
{
	int i = 0;
	int sum = 0;
	for(i = cont-1; i>=0;i--)
	{
		sum = sum + tinv[i]*(int)pow(10,cont-i-1);
	}
	return sum;
}

int next(int x)
{
	int e=0;
	int guar;
	guar = x;
	int di,mo;
	int p;
	int sea=0;
	int i;

	//lo invierto
	invertir(x);

	for(i =(cont-1); i>=0 ; i--)
	{
		if ( sea == 1 && t[i] != 4 )
		{
			t[i] = 4;

		}

		if ( t[i]< 4 && sea==0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( t[i]> 4 && t[i]< 7 && sea == 0)
		{
			t[i] = 7;
			sea = 1;
		}
		if( t[i] > 7 && i==(cont-1) && sea ==0 )
		{
			t[i] = 4;
			t[i+1] = 4;
			cont++;
			sea = 1;
		}
		if( t[i] > 7 && i!=(cont-1) && sea == 0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( (t[i] == 4 && (t[i-1]==8 || t[i-1]==9) ) && sea == 0)
		{
			t[i-1] = 4;
			t[i] = 7;
		}
		if( (t[i] == 7 && (t[i-1]==8 || t[i-1]==9)) && sea ==0 )
		{
			t[i] = 8;
			t[i-1] = 7;
			i = i+1;
		}

	}

	invertir_array();
	p = array_int();
	//	printf("\n%d",p);
	return p;

	/*
	while( x != 0 )
	{
		mo = x%10;
		if( mo == 4 || mo == 7)
		{
			x = x/10;
		}
		else
		{
		    x = guar+1;
		    guar = x;
		}
	}
	return guar;
	*/
}

int main(void)
{
	int i,j,ini,fin,n,s=0;
	scanf("%d",&ini); //inicio
	scanf("%d",&fin); //fin

	for(i=ini;i<=fin;i++)
	{
		s += next(i);
	}
	printf("%d",s);

}

#include <stdio.h>
#include <inttypes.h>
#include <math.h>

int t[100];
int tinv[100];
int cont;

void invertir(int x)
{
	cont=0;
	int i=0,mo,di;
	while(x !=0 )
	{
		mo = x%10;
		t[i] = mo;
		i++;
		x = x/10;
		cont++;
	}
}

void invertir_array(void)
{
	int i;
	for(i = 0; i<cont ;i++)
	{
		tinv[i] = t[cont-i-1];
	}
}
int64_t array_int(void)
{
	int i = 0;
	int64_t sum = 0;
	for(i = cont-1; i>=0;i--)
	{
		sum = sum + (int64_t)tinv[i]*(int)ceil((float)(pow(10,cont-i-1)));
	}
	return sum;
}

int64_t next(int x)
{
	int e=0;
	int guar;
	guar = x;
	int di,mo;
	int64_t p;
	int sea=0;
	int i;

	//lo invierto
	invertir(x);

	for(i =(cont-1); i>=0 ; i--)
	{
		if ( sea == 1 && t[i] != 4 )
		{
			t[i] = 4;
		}

		if ( t[i]< 4 && sea==0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( t[i]> 4 && t[i]< 7 && sea == 0)
		{
			t[i] = 7;
			sea = 1;
		}
		if( t[i] > 7 && i==(cont-1) && sea ==0 )
		{
			t[i] = 4;
			t[i+1] = 4;
			cont++;
			sea = 1;
		}
		if( t[i] > 7 && i!=(cont-1) && sea == 0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( (t[i] == 4 && (t[i-1]==8 || t[i-1]==9) ) && sea == 0)
		{
			t[i-1] = 4;
			t[i] = 7;
		}
		if( (t[i] == 7 && (t[i-1]==8 || t[i-1]==9)) && sea ==0 )
		{
			t[i] = 8;
			t[i-1] = 7;
			i = i+1;
		}

	}

	invertir_array();

	p = array_int();
	//printf("%lf ",p);
	return p;

	/*
	while( x != 0 )
	{
		mo = x%10;
		if( mo == 4 || mo == 7)
		{
			x = x/10;
		}
		else
		{
		    x = guar+1;
		    guar = x;
		}
	}
	return guar;
	*/
}

int main(void)
{
	int i,j,ini,fin,n;
	int64_t s=0;
	scanf("%d",&ini); //inicio
	scanf("%d",&fin); //fin

	for(i=ini;i<=fin;i++)
	{
		s += next(i);
	}
	printf("%" PRId64 "\n",s);

}

#include <stdio.h>
#include <math.h>

int t[10000000];
int tinv[10000000];
int cont;

void invertir(int x)
{
	cont=0;
	int i=0,mo,di;
	while(x !=0 )
	{
		mo = x%10;
		t[i] = mo;
		i++;
		x = x/10;
		cont++;
	}
}

void invertir_array(void)
{
	int i;
	for(i = 0; i<cont ;i++)
	{
		tinv[i] = t[cont-i-1];
	}
}
int array_int(void)
{
	int i = 0;
	int sum = 0;
	for(i = cont-1; i>=0;i--)
	{
		sum = sum + tinv[i]*(int)ceil((float)(pow(10,cont-i-1)));
	}
	return sum;
}

int next(int x)
{
	int e=0;
	int guar;
	guar = x;
	int di,mo;
	int p;
	int sea=0;
	int i;

	//lo invierto
	invertir(x);

	for(i =(cont-1); i>=0 ; i--)
	{
		if ( sea == 1 && t[i] != 4 )
		{
			t[i] = 4;

		}

		if ( t[i]< 4 && sea==0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( t[i]> 4 && t[i]< 7 && sea == 0)
		{
			t[i] = 7;
			sea = 1;
		}
		if( t[i] > 7 && i==(cont-1) && sea ==0 )
		{
			t[i] = 4;
			t[i+1] = 4;
			cont++;
			sea = 1;
		}
		if( t[i] > 7 && i!=(cont-1) && sea == 0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( (t[i] == 4 && (t[i-1]==8 || t[i-1]==9) ) && sea == 0)
		{
			t[i-1] = 4;
			t[i] = 7;
		}
		if( (t[i] == 7 && (t[i-1]==8 || t[i-1]==9)) && sea ==0 )
		{
			t[i] = 8;
			t[i-1] = 7;
			i = i+1;
		}

	}

	invertir_array();
	p = array_int();
	//	printf("\n%d",p);
	return p;

	/*
	while( x != 0 )
	{
		mo = x%10;
		if( mo == 4 || mo == 7)
		{
			x = x/10;
		}
		else
		{
		    x = guar+1;
		    guar = x;
		}
	}
	return guar;
	*/
}

int main(void)
{
	int i,j,ini,fin,n,s=0;
	scanf("%d",&ini); //inicio
	scanf("%d",&fin); //fin

	for(i=ini;i<=fin;i++)
	{
		s += next(i);
	}
	printf("%d",s);

}

#include <stdio.h>
#include <math.h>

int t[100];
int tinv[100];
int cont;

void invertir(int x)
{
	cont=0;
	int i=0,mo,di;
	while(x !=0 )
	{
		mo = x%10;
		t[i] = mo;
		i++;
		x = x/10;
		cont++;
	}
}

void invertir_array(void)
{
	int i;
	for(i = 0; i<cont ;i++)
	{
		tinv[i] = t[cont-i-1];
	}
}
long long array_int(void)
{
	int i = 0;
	long long sum = 0;
	for(i = cont-1; i>=0;i--)
	{
		sum = sum + tinv[i]*(int)ceil((float)(pow(10,cont-i-1)));
	}
	return sum;
}

long long next(int x)
{
	int e=0;
	int guar;
	guar = x;
	int di,mo;
	long long p;
	int sea=0;
	int i;

	//lo invierto
	invertir(x);

	for(i =(cont-1); i>=0 ; i--)
	{
		if ( sea == 1 && t[i] != 4 )
		{
			t[i] = 4;
		}

		if ( t[i]< 4 && sea==0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( t[i]> 4 && t[i]< 7 && sea == 0)
		{
			t[i] = 7;
			sea = 1;
		}
		if( t[i] > 7 && i==(cont-1) && sea ==0 )
		{
			t[i] = 4;
			t[i+1] = 4;
			cont++;
			sea = 1;
		}
		if( t[i] > 7 && i!=(cont-1) && sea == 0 )
		{
			t[i] = 4;
			sea = 1;
		}
		if( (t[i] == 4 && (t[i-1]==8 || t[i-1]==9) ) && sea == 0)
		{
			t[i-1] = 4;
			t[i] = 7;
		}
		if( (t[i] == 7 && (t[i-1]==8 || t[i-1]==9)) && sea ==0 )
		{
			t[i] = 8;
			t[i-1] = 7;
			i = i+1;
		}

	}

	invertir_array();

	p = array_int();

	return p;

	/*
	while( x != 0 )
	{
		mo = x%10;
		if( mo == 4 || mo == 7)
		{
			x = x/10;
		}
		else
		{
		    x = guar+1;
		    guar = x;
		}
	}
	return guar;
	*/
}

int main(void)
{
	int i,j,ini,fin,n;
	long long s=0;
	scanf("%d",&ini); //inicio
	scanf("%d",&fin); //fin

	for(i=ini;i<=fin;i++)
	{
		s += next(i);
	}
	printf("%ld",s);

}

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

long lucky_number[1024];
int id=0;
char s[10];

int is_lucky(long n){
    while (n>0) {
        if(n%10 != 4 && n%10 !=7) return 0;
        n=n/10;
    }
    return 1;
}

long next_lucky(long n){
    int i;
    for (i=0; i<1024; i++) {
        if(lucky_number[i] >= n) return lucky_number[i];
    }
}

int main(){

    // Generate lucky numbers
    long i;
    for (i=0; i<9; i++) {
        int j, k;
        for (k=0;k<=i;k++) {
            s[k] = '4';
        }
        //printf("%d\n", k);
        s[k] = '\0';
        //printf("%s\n", s);
        //lucky_number[index++] = atoi(s);
        //printf("%d\n", lucky_number[0]);
        do {
            lucky_number[id++] = atoi(s);
            //printf("%s\n", s);
            j = i;
            while (j >= 0 && s[j]== '7') {
                j--;
            }
            //printf("j=%d\n", j);
            //break;
            if (j>=0) {
                s[j] = '7';
                for (k=j+1; k<=i; k++) {
                    s[k] = '4';
                }
            }

        } while (j>=0);

    }
    lucky_number[id++] = 4444444444;
    //printf("%ld\n", next_lucky(7));
    //for(i=0; i<id; i++) printf("%d\n", lucky_number[i]);

    long l,r, sum=0;
    //long i, count=0;
    //printf("%d\n", is_lucky(4));
    scanf("%ld", &l);
    scanf("%ld", &r);
    for (i=l; i<=r; i++) {
        long next = next_lucky(i);
        //printf("next=%ld\ni=%ld\n", next, i);
        if(next <= r){
            sum += next*(next-i+1);
            i = next;
        }else{
            sum += next*(r-i+1);
            break;
        }
    }
    printf("%ld\n", sum);

    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#define min(a, b) ((a < b) ? (a) : (b))

long long l, r, answ, t = 1;
long long a[10];
long long ans[100000];
int n;

int
analyze(void)
{
    int i, nonzero = 0;
    long long tmp = 0;
    for(i = 9; i >= 0; --i){
        if(a[i] == 0 && nonzero){
            return 1;
        }
        tmp = tmp * 10 + a[i];
        if (a[i] != 0){
            nonzero = 1;
        }
    }
    if(tmp >= r){
        ans[n++] = tmp;
        return 0;
    }
    if(tmp >= l){
        ans[n++] = tmp;
    }
    return 1;
}

void
go(int i)
{
    if(!t){
        return;
    }
    if (i == -1){
        t = analyze();
        return;
    }
    a[i] = 0;
    go(i - 1);
    a[i] = 4;
    go(i - 1);
    a[i] = 7;
    go(i - 1);
}

int
main(void)
{
    scanf("%I64d%I64d", &l, &r);
    go(9);
    int i;
    for(i = 1; i < n; ++i){
        answ += (min(r, ans[i]) - ans[i - 1]) * ans[i];
    }
    answ += (ans[0] - l + 1) * ans[0];
    printf("%I64d", answ);
    return 0;
}

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void gen(long long int *a)
{
  int i;
  a[2]=4;
  a[3]=7;
  for(i=2;i<=2048;i++){
    //heaps are beautiful
    a[i<<1]=a[i]*10+4;
    a[(i<<1)+1]=a[i]*10+7;
    //      printf("%lld %lld\n",a[i<<1],a[(i<<1)+1]);
  }
}
int main()
{
  long long int b[10000],*a;
  long long int ans,till;
  int l,r,i;
  gen(b);
  a=b+2;//the first two indices of b contain junk
  scanf("%d%d",&l,&r);
  i=0;
  while(a[i]<l)
    i++;
  till=((r>=a[i])?a[i]:r);
  ans=a[i]*(till-l+1);
  //   printf("%lld+",ans);

  for(i=i+1;a[i]<=r;i++)
    ans+=(a[i]*(a[i]-a[i-1]));
  if(a[i-1]<r)
    ans+=(a[i]*(r-a[i-1]));
   printf("%lld\n",ans);
  //printf("%I64d\n",ans);
  return 0;
}

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void gen(long long int *a)
{
   int i;
   a[2]=4;
   a[3]=7;
   for(i=2;i<=2048;i++){
      //heaps are beautiful
      a[i<<1]=a[i]*10+4;
      a[(i<<1)+1]=a[i]*10+7;
//      printf("%lld %lld\n",a[i<<1],a[(i<<1)+1]);
   }
}
int main()
{
   long long int b[10000],*a;
   long long int ans,till;
   int l,r,i;
   gen(b);
   a=b+2;//the first two indices of b contain junk
   scanf("%d%d",&l,&r);
   i=0;
   while(a[i]<l)
      i++;
   till=((r>=a[i])?a[i]:r);
   ans=a[i]*(till-l+1);
//   printf("%lld+",ans);

   for(i=i+1;a[i]<=r;i++)
      ans+=(a[i]*(a[i]-a[i-1]));
   ans+=(a[i]*(r-a[i-1]));
  // printf("%lld\n",ans);
   printf("%I64d\n",ans);
   //cout>>ans;
   return 0;
}

#include <stdio.h>
__int64 s[100005],snum;
int c[2]={4,7};

void dfs(__int64 n,__int64 L,__int64 l){
	__int64 m = n;
	n = m*10 + c[0];
	if(l == L)	s[snum++] = n;
	else		dfs(n,L,l+1);

	n = m*10 + c[1];
	if(l == L)	s[snum++] = n;
	else		dfs(n,L,l+1);
}

void init(){
	__int64 i,j,k;
	s[0] = 0;
	snum = 1;
	for(i=1;i<=9;i++){
		dfs(0,i,1);
	}
}

int main()
{
	__int64 a,b,i,flag = 0;
	init();
	scanf("%I64d%I64d",&a,&b);
	for(i=1;i<snum;i++){
		if(s[i]>=a){
			flag = i; break;
		}
	}
	if(b<=s[flag]){
		printf("%I64d\n",(b-a+1)*s[flag]);
	}else{
		int ans = (s[flag]-a+1)*s[flag];
		int start = s[flag]+1;
		for(i = flag;;i++){
			if(s[i] >= b){
				ans += (b-start+1)*s[i];
				break;
			}
			else{
				ans += (s[i]-start+1)*s[i];
			}
		}
		printf("%I64d\n",ans);
	}

	return 0;
}

#include<stdio.h>
typedef long long int llint;
llint lucky[3000];
int cnt=0;
void backtrack(int now,int f,char ans[])
{
  int i;
  if(now==f)
  {
    llint tmp=0;
    for(i=0;i<now;++i) tmp=tmp*10+ans[i]-'0';
    lucky[cnt++]=tmp;
    return;
  }
  ans[now]='4';
  backtrack(now+1,f,ans);
  ans[now]='7';
  backtrack(now+1,f,ans);
}
int main(void)
{
  int i;
  llint tot,l,r,bl,br,mid,posl,posr,top;
  char ans[12];
  for(i=1;i<=10;++i) backtrack(0,i,ans);
  while(scanf("%I64d %I64d",&l,&r)!=EOF)
  {
    tot=0;
    bl=0;
    br=cnt-1;
    while(bl<=br)
    {
      mid=(bl+br)/2;
      if(l>lucky[mid]) bl=mid+1;
      else br=mid-1;
    }
    posl=bl;
    bl=0;
    br=cnt-1;
    while(bl<=br)
    {
      mid=(bl+br)/2;
      if(r>lucky[mid]) bl=mid+1;
      else br=mid-1;
    }
    posr=bl;

    tot+=(lucky[posl]*(lucky[posl]-l+1));
    if(r!=lucky[posr])
    {
      tot+=(lucky[posr]*(r-lucky[posr-1]));
      top=posr-1;
    }
    else top=posr;
    for(i=posl+1;i<=top;++i) tot+=(lucky[i]*(lucky[i]-lucky[i-1]));

    printf("%I64d\n",tot);
  }
  return 0;
}