#include<stdio.h>
int main()
{
	int a,b,i,sum=0,c,d;
	scanf("%d%d",&a,&b);
	for(i=a;i<=b;i++)
	{
		d=i;
		while(d!=0)
		{
			c=d%10;
			if(c==0)
			sum=sum+6;
			if(c==1)
			sum=sum+2;
			if(c==2)
			sum=sum+5;
			if(c==3)
			sum=sum+5;
			if(c==4)
			sum=sum+4;
			if(c==5)
			sum=sum+5;
			if(c==6)
			sum=sum+6;
			if(c==7)
			sum=sum+3;
			if(c==8)
			sum=sum+7;
			if(c==9)
			sum=sum+6;
			d=d/10;
		}
	}
	printf("%d",sum);
return 0;
}

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

//1〜nに含まれるcountの個数を求める
unsigned long long solve(unsigned long long n,int count,int base){
	unsigned long long r=0; //結果
	unsigned long long lower=0; //処理している桁より下の桁の合計
	unsigned long long digits=0,expbase=1;
	for(;n;digits++,expbase*=base,n/=base){
		unsigned long long d=digits*expbase/base; //0,1,20,300,4000,...
		unsigned long long current_digit=n%base;
		r+=current_digit*d;
		if(current_digit==count)r+=lower+1;
		if(current_digit>=count+1)r+=expbase;
		lower+=current_digit*expbase;
		if(count==0)r-=expbase;
	}
	return r;
}

int d[]={6,2,5,5,4,5,6,3,7,6};
int main(){
	int base=10;

	unsigned long long n,m,r=0;
	scanf("%I64d%I64d",&n,&m);
	int i=0;
	for(;i<10;i++)r+=d[i]*(solve(m,i,base)-solve(n-1,i,base));
	printf("%I64d\n",r);
}

#include<stdio.h>
int main()
{
    int a, b, sum=0, s;
    scanf("%d%d",&a,&b);
    for (int i=a; i<=b; i++)
        for (int j=i; j!=0; j/=10){
            s=j%10;
            switch (s){
                case 0 :
                case 6 :
                case 9 : sum+=6; break;
                case 1 : sum+=2; break;
                case 2 :
                case 3 :
                case 5 : sum+=5; break;
                case 4 : sum+=4; break;
                case 7 : sum+=3; break;
                case 8 : sum+=7; break;
            }
        }
    printf("%d",sum);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <time.h>
#define SIZE 1000002

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

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

long sum(int seg[], long x)
{
    long k = 0;
    while (x > 0)
    {
        k += seg[x % 10];
        x /= 10;
    }
    return k;
}
/*****************************************************************************/
int main(void)
{
    long m, n, k, i;
    int seg[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    scanf("%ld %ld", &m, &n);
    k = 0;
    for (i = m; i <= n; ++i)
    {
        k += sum(seg, i);
    }
    printf("%ld\n", k);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include<string.h>
int main()
{
  int arra[]={6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
  int a, b;
  int o=0 ;
  int i,c;
  scanf("%d%d", &a, &b) ;
  for ( i=a ; i<=b ;  i++)
  {
        c=i ;
        while (c)
        {
                o +=arra[c%10] ;
                c  /=10 ;
        }
  }
  printf("%d\n", o) ;
  return 0 ;
}

#include<stdio.h>
int call(int);
int main()
{
int a,b;
scanf("%d%d",&a,&b);
int i,j,k,count=0;
for(i=a;i<=b;i++){ j=i;
            for(;j>0;){
            k=j%10;
            count=call(k)+count;
            j=j/10;
            }
}
printf("%d",count);
return 0;
}
int call(int c){
switch(c){
 case 0: return 6;
 case 1: return 2;
 case 2: return 5;
 case 3: return 5;
 case 4: return 4;
 case 5: return 5;
 case 6: return 6;
 case 7: return 3;
 case 8: return 7;
 case 9: return 6;
}
}

#include <stdio.h>

int main(void)
{
	int a, b, k, m, num = 0;

	scanf("%d %d", &a, &b);
	for(; a <= b; a++)
	{
		m = a;
		for(; m != 0;)
		{
			k = m % 10;
			switch(k)
			{
				case 0 : num += 6; break;
				case 1 : num += 2; break;
				case 2 : num += 5; break;
				case 3 : num += 5; break;
				case 4 : num += 4; break;
				case 5 : num += 5; break;
				case 6 : num += 6; break;
				case 7 : num += 3; break;
				case 8 : num += 7; break;
				case 9 : num += 6; break;
			}
			m /= 10;
		}
	}
	printf("%d", num);

	return 0;
}

#include<stdio.h>
int main()
{
    unsigned long long int sum=0;
    int x,z,y,dif,i,temp;
    scanf("%d %d",&x,&y);
        dif=y-x;
        for(i=0;i<=dif;i++)
        {
            z=x;
            while(z!=0)
            {
            temp=z%10;
    if(0==temp)
        sum=sum+6;
    if(1==temp)
        sum=sum+2;
    if(2==temp)
        sum=sum+5;
    if(3==temp)
        sum=sum+5;
    if(4==temp)
        sum=sum+4;
    if(5==temp)
        sum=sum+5;
    if(6==temp)
        sum=sum+6;
    if(7==temp)
        sum=sum+3;
    if(8==temp)
        sum=sum+7;
    if(9==temp)
        sum=sum+6;
         z=z/10;
        }
        x++;
        }
    printf("%llu",sum);
    return 0;
}

#include<stdlib.h>
#include<stdio.h>
int a[10]={6,2,5,5,4,5,6,3,7,6},x,y,i,sum,tmp,digit;
int main(){
    scanf("%d %d",&x,&y);
    for (i=x; i<=y; i++) {
        tmp=i;
        while(tmp){
            digit=tmp%10;
            sum+=a[digit];
            tmp/=10;
        }
    }
    printf("%d",sum);
    return 0;
}

#include <stdio.h>

const int seg[10] = { 6, 2, 5, 5, 4, 5, 6, 3, 7, 6 };

int a, b;

int main(void)
{
    int i, num, count;

    /* Reads the input */
    scanf("%d%d", &a, &b);

    /* Count */
    count = 0;

    for (i = a; i <= b; ++i)
    {
        num = i;

        /* Count each digits */
        while (num > 0)
        {
            count += seg[num % 10];
            num /= 10;
        }
    }

    /* Writes the answer */
    printf("%d\n", count);

    return 0;
}

#include <stdio.h>
#include <stdlib.h>
int Num(long a , long b);
int Analysize(int i);
int GetSeg(int a);

int main()
{
    long a,b;
    scanf("%ld %ld",&a,&b);
    long result=Num(a,b);
    printf("%ld",result);
    return 0;
}

int Num(long a , long b)
{
    long result=0;

    while(a<=b)
    {
        result+=GetSeg(a);
        a++;
    }
    return result;
}

int Analysize(int i)
{
    int d;
    switch (i)
    {
    case 1:
        d=2;
        break;
    case 7:
        d=3;
        break;
    case 2:
    case 3:
    case 5:
        d=5;
        break;
    case 4:
        d=4;
        break;
    case 0:
    case 6:
    case 9:
        d=6;
        break;
    case 8:
        d=7;
        break;
    }
    return d;
}

int GetSeg(int a){
    int result=0;
while(a!=0){
    result+=Analysize(a%10);
    a/=10;
}
return result;
}

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

int main()
{
    int m,n,i,j,x,c=0;
    scanf("%d %d",&m,&n);
    for(i=m;i<=n;i++){
            j=i;
        while(j>0){
            x=j%10;
            j=j/10;
            switch(x){
            case 0:
            case 6:
            case 9:
                c=c+6;
                break;
            case 1:
                c=c+2;
                break;
            case 2:
            case 3:
            case 5:
                c=c+5;
                break;
            case 4:
                c=c+4;
                break;
            case 7:
                c=c+3;
                break;
            case 8:
                c=c+7;
                break;

            }

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

}

#include<stdio.h>
int a[] = {6,2,5,5,4,5,6,3,7,6};
int s(int n)
{
int r = 0;
while(n){r+= a[n%10];n/=10;}
return r;
}
int main()
{
int ans = 0;
int n,m;
scanf("%d%d",&n,&m);
int x;
for(x=n;x<=m;x++)
ans+= s(x);
printf("%d\n",ans);
return 0;
}

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

int main(){
    int a,b,i,j;
    long long unsigned int count=0;
    char str[8];
    scanf("%d %d",&a,&b);

    for(i=a;i<=b;i++){
        j=0;
        itoa(i,str,10);
        while(str[j]!=0){
            switch(str[j]){
                case '0':   count+=6;
                            break;
                case '1':   count+=2;
                            break;
                case '2':   count+=5;
                            break;
                case '3':   count+=5;
                            break;
                case '4':   count+=4;
                            break;
                case '5':   count+=5;
                            break;
                case '6':   count+=6;
                            break;
                case '7':   count+=3;
                            break;
                case '8':   count+=7;
                            break;
                case '9':   count+=6;
                            break;

                }
                j++;
        }

    }
    printf("%I64d\n",count);

    return 0;

}

#include<stdio.h>
int a[20]={6,2,5,5,4,5,6,3,7,6};
int ha(int n)
{
    int m,sum=0;
    while(n)
    {
        m=n%10;
        n=n/10;
        sum+=a[m];
    }
    return(sum);
}
int main()
{int m,n,sum,i;
scanf("%d%d",&n,&m);
sum=0;
for(i=n;i<=m;i++)
    sum+=ha(i);
    printf("%d\n",sum);
    return 0;
}

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>

#define PI 3.141592653589793
#define max(a,b) (a < b) ? (b) : (a)
#define min(a,b) (a > b) ? (b) : (a)
#define FOR(i,a,b) for(i = a ; i <= b ; i++)
#define ROF(i,a,b) for(i = a ; i >= b ; i--)
#define RAD(x) ((x)*PI)/180
#define y1 y_1
#define ll long long
#define endl printf("\n")
#define MAX 100005

int a, b, i, x, ans, t[10] = {6, 2, 5, 5 ,4, 5 ,6, 3, 7, 6};

int main () {
	scanf("%d %d",&a ,&b);
	FOR(i, a, b){
		x = i;
		while(x){
			ans += t[x%10];
			x/=10;
		}
	}
	printf("%d\n",ans);
	return 0;
}

#include<stdio.h>
int arr[10]={6,2,5,5,4,5,6,3,7,6},t;
int hesapla(int x){
	if(x>=10){
		t+=arr[x%10];
		x/=10;
		return hesapla(x);}
	else
		return arr[x]+t;}
main(){
	int i,z=0,a,b;
	scanf("%d%d",&a,&b);
	for(i=a;i<=b;i++){
		z+=hesapla(i);
		t=0;
	}
	printf("%d",z);

}

#include <stdio.h>
int segCalc(int number){
	if(number==4){
		return 4;
	}else if (number==1){
		return 2;
	}else if (number==2||number==5||number==3){
		return 5;
	}else if (number==6||number==0||number==9){
		return 6;
	}else if (number==7){
		return 3;
	}else if (number==8){
		return 7;
	}

}
long findSeg(long i){
	long seg;
	int temp;
	if((i)/10==0){
		seg= segCalc(i%10);
		return seg;
	}
	else{
		temp=i%10;
		seg=segCalc(temp);

		return seg+findSeg(i/10);
	}

}
int main() {
	// your code goes here
	long a,b,sum=0,i;

	scanf("%ld %ld",&a,&b);
	for(i=a;i<=b;i++){

	sum+=	findSeg(i);

	}

	printf("%ld",sum);
	return 0;
}

#include<stdio.h>
int main()
{
    int i,a,b,z,sum=0,o,u,j;
    scanf("%d%d",&a,&b);
    for(i=a;i<=b;i++)
    {
     z=i;
     for(j=0;z!=0;j++)
     {
    o=z%10;
          if(o==0)
     {
         sum=sum+6;
     }
     else if(o==1)
     {
         sum=sum+2;
     }
          else if(o==2)
     {
         sum=sum+5;
     }
          else if(o==3)
     {
         sum=sum+5;
     }
          else if(o==4)
     {
         sum=sum+4;
     }
          else if(o==5)
     {
         sum=sum+5;
     }
          else if(o==6)
     {
         sum=sum+6;
     }
          else if(o==7)
     {
         sum=sum+3;
     }
          else if(o==8)
     {
         sum=sum+7;
     }
          else if(o==9)
     {
         sum=sum+6;
     }
     z=z/10;
     }

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

#include <stdio.h>

int main() {
    int num[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    int ans, t;
    int a, b;

    scanf("%d %d", &a, &b);
    ans = 0;
    for (int i = a;i <= b;i ++) {
        t = i;
        while (t) {
            ans += num[t % 10];
            t /= 10;
        }
    }
    printf("%d\n", ans);

    return 0;
}

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

//			  0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }
int CoS[] = { 6, 2, 5, 5, 4 ,5, 6, 3, 7, 6 };

int GetCountOfSegment(int a)
{
	int iSum = 0;
	int i = 0;
	int iLen ;

	char strA[20];
	sprintf(strA,"%d",a);

	iLen = strlen( strA );

	for( i = 0 ; i < iLen ; i++ )
	{
		iSum += CoS[ strA[i]-'0' ];
	}

	return iSum;
}

int main()
{

	int a,b;
	int iSum = 0;
	int i;

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

	for( i = a ; i <= b ; i++ )
	{
		iSum += GetCountOfSegment( i );
	}

	printf("%d",iSum);

	return 0;
}

#include<stdio.h>
int main()
{
    int i,a,b,segment=0,digit;
    scanf("%d%d",&a,&b);
    for(i=a;i<=b;i++)
    {  a=i;
       while(a!=0)
       {
          digit=a%10;
          if(digit==0) segment+=6;
          if(digit==1) segment+=2;
          if(digit==2) segment+=5;
          if(digit==3) segment+=5;
          if(digit==4) segment+=4;
          if(digit==5) segment+=5;
          if(digit==6) segment+=6;
          if(digit==7) segment+=3;
          if(digit==8) segment+=7;
          if(digit==9) segment+=6;
          a=a/10;
        }
    }
    printf("%d",segment);
}

#include<stdio.h>
#include<process.h>
#include<string.h>
#include<math.h>
int main()
{
	int a, b,k,j,sum=0;
	scanf("%d%d", &a, &b);
	for (int i = a; i < b + 1; i++){
		j = i;
		while (j != 0){
			k=j % 10;
			j=j / 10;
			switch (k){
			case 1:sum += 2; break;
			case 2:sum += 5; break;
			case 3:sum += 5; break;
			case 4:sum += 4; break;
			case 5:sum += 5; break;
			case 6:sum += 6; break;
			case 7:sum += 3; break;
			case 8:sum += 7; break;
			case 9:sum += 6; break;
			case 0:sum += 6; break;
			}
		}

	}
	printf("%d", sum);

	return 0;
}

#include<stdio.h>
#include<math.h>
#include<string.h>
int number(int a)
{
	int i,num=0;
	int b[10]={6,2,5,5,4,5,6,3,7,6};
	while(1)
	{
		i=a%10;
		num+=b[i];
		if(a/10==0) break;
		a/=10;
	}
	return num;

}
int main()
{
	int a,b,i,num=0;
	scanf("%d%d",&a,&b);
	for(i=a;i<=b;++i)
	{
		num+=number(i);
	}
	printf("%d",num);
	return 0;
}

//
//  main.cpp
//  B
//
//  Created by KJBS2 on 2016. 1. 22..
//  Copyright (c) 2016년 KJBS2. All rights reserved.
//

#include <stdio.h>

int Plus[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};

int main() {
    int a, b;
    scanf("%d%d", &a, &b);

    int result = 0;
    for(int i=a; i<=b; i++) {
        int now = i;
        while(now) {
            result += Plus[now%10];
            now /= 10;
        }
    }

    printf("%d\n", result);

    return 0;
}

#include<stdio.h>

int main()
{
    int a, b;
    long long cnt=0;
    scanf("%d%d",&a,&b);
    for(int i=a;i<=b;i++)
    {
    int num=i;
    while(num)
    {
    int rem=num%10;
    if(rem==1)
    cnt+=2;
    else if(rem==2||rem==3||rem==5)
    cnt+=5;
    else if(rem==6||rem==9||rem==0)
    cnt+=6;
    else if(rem==8)
    cnt+=7;
    else if(rem==7)
    cnt+=3;
    else if(rem==4)
    cnt+=4;
    num/=10;
    }
    }
    printf("%lld",cnt);
    return 0;
}

#include<stdio.h>
int F(int n){
	switch(n){
		case 0:
			return 6;
		case 1:
			return 2;
		case 2:
			return 5;
		case 3:
			return 5;
		case 4:
			return 4;
		case 5:
			return 5;
		case 6:
			return 6;
		case 7:
			return 3;
		case 8:
			return 7;
		case 9:
			return 6;
	}
}
int main(){
	int a,b,n,m,sum = 0;
	scanf("%d %d",&a,&b);
	for(int i = a; i <= b; i++){
		n = i;
			while(n>0){
				sum += F((n%10));
				n/=10;
			}

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

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

#define debug(name, arg) printf("debug(%s%d) \n", name, arg)

int solution(int arg, int arg1) {
	int ret = 0;
	int i;
	int rem;
	int number;

	for(i = arg; i <= arg1; ++i) {
		number = i;
		while(number) {
			rem = number % 10;

			switch(rem) {
				case 0 : ret += 6; break;
				case 1 : ret += 2; break;
				case 2 : ret += 5; break;
				case 3 : ret += 5; break;
				case 4 : ret += 4; break;
				case 5 : ret += 5; break;
				case 6 : ret += 6; break;
				case 7 : ret += 3; break;
				case 8 : ret += 7; break;
				case 9 : ret += 6; break;
			}

			number = number / 10;
		}
	}

	return ret;
}

int main()
{
	int a, b;
	int sol;

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

	//debug("a = ",a);
	//debug("b = ",b);

	sol = solution(a, b);
	printf("%d \n", sol);
	//debug("sol = ", sol);

	return 0;
}

#include<stdio.h>

int main(){
    int a,b,total=0;
    int segments[]={6,2,5,5,4,5,6,3,7,6};
    int j;
    scanf("%d%d",&a,&b);

    for (int i=a; i<=b; i++) {
        a=i;
        while (a>=10) {
            j=a%10;
            a=a/10;
            total+=segments[j];
        }
        total+=segments[a];
    }
    printf("%d",total);

}

//shauwaaa
//shauwaaa
//shauwaaa
//shauwaaa
//shauwaaa
//shauwaaa
//shauwaaa
//shauwaaa
//shauwaaa
//shauwaaa
//shauwaaa
//shauwaaa

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

    int y,i,a,b,x,s=0;

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

    for (i=a; i<=b; i++)
    {
        y=i;
        while(y!=0)
        {
            x=(y%10);
            y=(y/10);

            switch (x)
            {
            case 0 :
                s=s+6;
                break;
            case 1 :
                s=s+2;
                break;
            case 2 :
                s=s+5;
                break;
            case 3 :
                s=s+5;
                break;
            case 4 :
                s=s+4;
                break;
            case 5 :
                s=s+5;
                break;
            case 6 :
                s=s+6;
                break;
            case 7 :
                s=s+3;
                break;
            case 8 :
                s=s+7;
                break;
            case 9 :
                s=s+6;
                break;
            }
            if (y==0)
            {
                break;
            }
        }
    }

    printf("%d",s);

}

#include<stdio.h>

int main() {
        int m;
        int n;
        unsigned long long sum=0;
        int i,j,k;
        int arr[10]={6,2,5,5,4,5,6,3,7,6};

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

        if(m==0)
                sum+=6;
        for(i=m;i<=n;i++) {
                j = i;
                while(j!=0) {
                        k = j%10;
                        j/=10;
                        sum+=arr[k];
                }
        }
        printf("%llu",sum);
        return 0;
}

#include<stdio.h>
int main()
{
	unsigned long long a,b,num,number;
	int sum = 0,total = 0;
	int last_dig;

	scanf("%llu %llu",&a,&b);
	for(number = a; number<= b; number++)
	{
		num = number;
		while(1)
	   {
		 last_dig = num % 10;

 		 if(last_dig == 0){
 			total += 6;
		 }

		 else if(last_dig == 1){
			total += 2;
		 }

		 else if(last_dig == 2){
			total += 5;
		 }

		 else if(last_dig == 3){
			total += 5;
		 }

		 else if(last_dig == 4){
			total += 4;
		 }

		 else if(last_dig == 5){
			total += 5;
		 }

		 else if(last_dig == 6){
			total += 6;
		 }

		 else if(last_dig == 7){
			total += 3;
		 }

		 else if(last_dig == 8){
			total += 7;
		 }

		 else if(last_dig == 9){
			total += 6;
		 }

		 num = num/10;
		 if(num==0)
			break;
    	}
	}
	printf("%d",total);
	return 0;
}

#include <stdio.h>

int main()
{
    int a,b,i,k,m;
    long long sum=0;
    int ara[]={6,2,5,5,4,5,6,3,7,6};
    scanf("%d %d",&a,&b);

    for(i=a;i<=b;i++){
        k=i;
        while (k>0)
        {
            m=k%10;
            k = k/10;
            sum = sum+ara[m];
        }
    }

    printf("%lld\n",sum);

    return 0;
}

#include <stdio.h>

int cnt(int d) {
	switch (d) {
		case 0:
			return 6;
		case 1:
			return 2;
		case 2:
			return 5;
		case 3:
			return 5;
		case 4:
			return 4;
		case 5:
			return 5;
		case 6:
			return 6;
		case 7:
			return 3;
		case 8:
			return 7;
		case 9:
			return 6;
	}
	return 0;
}

int segments(int n) {
	return n < 10 ? cnt(n) : segments(n / 10) + cnt(n % 10);
}

int main() {
	int n, a, b, sum;

	scanf("%d%d", &a, &b);
	sum = 0;
	for (n = a; n <= b; n++)
		sum += segments(n);
	printf("%d\n", sum);
	return 0;
}

#include<stdio.h>

#define ll long long int

int main()
{
	ll arr[10]={6,2,5,5,4,5,6,3,7,6};
	ll a,b,i,j,count=0,t;

	scanf("%lld%lld",&a,&b);
	for(i=a;i<=b;i++)
	{
		if(i>9)
		{
			for(j=i;;)
			{
				t=j%10;
				count+=arr[t];
				j=j/10;
				if(j==0) break;
			}
		}
		else
		{
			count+=arr[i];
		}
	}
	printf("%lld\n",count);
}

#include <stdio.h>

int main()
{
    long long int test,n,i,j,sum1,k,m,a,flag=0,count=0,b,c[10]={6,2,5,5,4,5,6,3,7,6},a1,b2;
  scanf("%lld%lld",&a,&b);
  count=0;
  for(i=a;i<=b;i++){
      k=i;
      while(k>0){
          count+=c[k%10];
          k/=10;
      }
  }
   printf("%lld",count);
    return 0;
}

#include <stdio.h>

int main()
{
    int a = 0, b = 0, tmp;
    int c;
    int sum = 0;
    scanf("%d", &a);
    scanf("%d", &b);
    for (int i = a; i <= b; i++)
    {
        tmp = i;
        while (tmp > 0)
        {
            c = tmp % 10;
            tmp = tmp / 10;
            if (c == 1)
                sum += 2;
            else if (c == 2 || c == 3 || c == 5)
                sum += 5;
            else if (c == 4)
                sum += 4;
            else if (c == 6 || c == 9 || c == 0)
                sum += 6;
            else if (c == 7)
                sum += 3;
            else if (c == 8)
                sum += 7;
        }
    }
    printf("\n %d", sum);
    return 0;
}

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

    int x,y,n,i,j,d;
    long int z=0;

    scanf("%d %d",&x,&y);
    int hey[10]={6,2,5,5,4,5,6,3,7,6};
    for(i=x;i<=y;i++){
        n=count(i);
        for(j=1;j<=n;j++){
        d=digit(i,j);
        z=z+hey[d];

        }
    }
        printf("%ld\n",z);

}
int count(int n)
{
    int c=0;
    while(n != 0)
    {
    n /= 10;
    c++;
    }

  return c;
}

int digit(int num,int n)
{
    int i;
    long int z1=1;
    for(i=1;i<=n;i++){
        z1=z1*10;

    }
    int y1=num%z1;
    long int z2=1;
    for(i=1;i<=n-1;i++){
    z2=z2*10;
    }
    int y2=y1/z2;
    return y2;

}

#include<stdio.h>
int main()
{
int p[]={6,2,5,5,4,5,6,3,7,6};
int num,sum,a,b,i;
scanf("%d%d",&a,&b);
sum=0;
for(i=a;i<=b;i++)
{
a=i;
while(a!=0)
{
num=a%10;
a=a/10;
sum=sum+p[num];
}
}
printf("%d\n",sum);
return 0;
}

#include<stdio.h>

int show[10]={6,2,5,5,4,5,6,3,7,6};
int count(int a){
	int counter=0;
	while(a>0){
		counter+=show[a%10];
		a=a/10;
	}
	return counter;
}

int main() {
	int a,b;
	scanf("%d%d",&a,&b);
	int i;
	long long total=0;
	for(i=a;i<=b;i++){
		total+=count(i);
	}
	printf("%lld\n",total);

	return 0;
}

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

int main()
{
    int seg[10]= {6,2,5,5,4,5,6,3,7,6};
    long a , b ,loopIndex , i;
    long sum = 0 ;
    scanf("%d %d", &a , &b);
    for(loopIndex=a;loopIndex<=b;loopIndex++)
    {
        i = loopIndex ;
        while(i>0)
        {
            sum+=seg[i%10];
            i/=10 ;
        }
    }
    printf("%d", sum);
}

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

int y,i,a,b,x,s;

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

s=0;
for (i=a;i<=b;i++){
y=i;
while(y!=0){
	x=(y%10);
	y=(y/10);

	switch (x){
		case 0 : s=s+6;
		        break;
		case 1 : s=s+2;
		        break;
		case 2 : s=s+5;
		        break;
		case 3 : s=s+5;
		        break;
		case 4 : s=s+4;
		        break;
		case 5 : s=s+5;
		        break;
		case 6 : s=s+6;
		        break;
		case 7 : s=s+3;
		        break;
		case 8 : s=s+7;
		        break;
		case 9 : s=s+6;
		        break;
	}
	if (y==0){
		break;
		}
}
}

printf("%d",s);

return 0;
}

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

int main()
{int a, b, i, intermediate;
long int segments = 0 ;

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

for ( i = a; i <= b; i++)
{

    intermediate = i;
    do {
            switch(intermediate % 10)
            {
                case 0: segments += 6; break;
                case 1: segments += 2; break;
                case 2: segments += 5; break;
                case 3: segments += 5; break;
                case 4: segments += 4; break;
                case 5: segments += 5; break;
                case 6: segments += 6; break;
                case 7: segments += 3; break;
                case 8: segments += 7; break;
                case 9: segments += 6; break;

            }

            intermediate = intermediate / 10;

    } while (intermediate != 0);

}

printf("%ld",segments);

    return 0;
}

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

int main ()
{
	int a,b,n=0;
	scanf("%d %d",&a,&b);
	for ( ;a<=b;a++)
	{
		int i=a;
		int t=1;
		while (i)
		{
			t = i % 10;
			switch (t)
			{
			case 0:
				n+=6;
				break;
			case 1:
				n+=2;
				break;
			case 2:
				n+=5;
				break;
			case 3:
				n+=5;
				break;
			case 4:
				n+=4;
				break;
			case 5:
				n+=5;
				break;
			case 6:
				n+=6;
				break;
			case 7:
				n+=3;
				break;
			case 8:
				n+=7;
				break;
			case 9:
				n+=6;
				break;
			}
			//printf ("%d\n",t);
			i /=10;
		}
	}
	printf ("%d",n);
	return 0;
}

#include<stdio.h>

int yes(int *t,int n)
{
	if(n>=10)
	return t[n%10]+yes(t,n/10);
	else return t[n];
}

int main(){
	int sig[]={6,2,5,5,4,5,6,3,7,6};
	int a,b,i,s=0;
	scanf("%d%d",&a,&b);
	for(i=a;i<=b;i++)
		s=s+yes(sig,i);
		printf("%d",s);
	return 0;
}

#include<stdio.h>
int cal(int x)
{
    if(x==0)
        return 6;
    else if(x==1)
        return 2;
    else if(x==2)
        return 5;
    else if(x==3)
        return 5;
    else if(x==4)
        return 4;
    else if(x==5)
        return 5;
    else if(x==6)
        return 6;
    else if(x==7)
        return 3;
    else if(x==8)
        return 7;
    else
        return 6;
}
int main()
{
    int a,b,i,ans=0,p;
    scanf("%d %d",&a,&b);
    for(i=a;i<=b;i++)
    {
        int t=i;
        while(t!=0)
        {
        p=t%10;
        ans=ans+cal(p);
        t=t/10;
        }
    }
    printf("%d",ans);
    return 0;
}

#include <stdio.h>
long long int sum=0;
void func(long int c)
{
   if(c==0)
	   sum+=6;
   else if(c==1)
	   sum+=2;
   else if(c==2)
	   sum+=5;
   else if(c==3)
	   sum+=5;
   else if(c==4)
	  sum+=4;
   else if(c==5)
	   sum+=5;
   else if(c==6)
	   sum+6;
   else if(c==7)
	   sum+=3;
   else if(c==8)
	   sum+=7;
   else
	   sum+=6;
}
int main()
{
	long int a,b,i,j;
	scanf("%ld %ld",&a,&b);
	for(i=a;i<=b;i++)
	{
		j=i;
		while(j>0)
		{
			func(j%10);
			j=j/10;
		}
	}
	printf("%lld\n",sum);
	return 0;
}

#include <stdio.h>
long long int sum=0;
void func(long int c)
{
   if(c==0)
	   sum+=6;
   else if(c==1)
	   sum+=2;
   else if(c==2)
	   sum+=5;
   else if(c==3)
	   sum+=5;
   else if(c==4)
	  sum+=4;
   else if(c==5)
	   sum+=5;
   else if(c==6)
	   sum+6;
   else if(c==7)
	   sum+=3;
   else if(c==8)
	   sum+=7;
   else
	   sum+=6;
}
int main()
{
	long int a,b,i,j;
	sum=0;
	scanf("%ld %ld",&a,&b);
	for(i=a;i<=b;i++)
	{
		j=i;
		while(j!=0)
		{
			func(j%10);
			j=j/10;
//			printf("%lld\n",sum);
		}
	}
	printf("%lld\n",sum);
	return 0;
}

#include <stdio.h>
long long int sum=0;
void func(long int c)
{
   if(c==0)
	   sum+=6;
   else if(c==1)
	   sum+=2;
   else if(c==2)
	   sum+=5;
   else if(c==3)
	   sum+=5;
   else if(c==4)
	  sum+=4;
   else if(c==5)
	   sum+=5;
   else if(c==6)
	   sum+6;
   else if(c==7)
	   sum+=3;
   else if(c==8)
	   sum+=7;
   else
	   sum+=6;
}
int main()
{
	long int a,b,i,j;
	scanf("%ld %ld",&a,&b);
	for(i=a;i<=b;i++)
	{
		j=i;
		while(j!=0)
		{
			func(j%10);
			j=j/10;
//			printf("%lld\n",sum);
		}
	}
	printf("%lld\n",sum);
	return 0;
}

#include<stdio.h>
int main()
{
    unsigned long long int sum=0;
    int x,z,y,dif,i,temp;
    scanf("%d %d",&x,&y);
    if(x>=9)
    {
        dif=y-x;
        for(i=0;i<=dif;i++)
        {
            z=x;
            while(z!=0)
            {
            temp=z%10;
    if(0==temp)
        sum=sum+6;
    if(1==temp)
        sum=sum+2;
    if(2==temp)
        sum=sum+5;
    if(3==temp)
        sum=sum+5;
    if(4==temp)
        sum=sum+4;
    if(5==temp)
        sum=sum+5;
    if(6==temp)
        sum=sum+6;
    if(7==temp)
        sum=sum+3;
    if(8==temp)
        sum=sum+7;
    if(9==temp)
        sum=sum+6;
         z=z/10;
        }
        x++;
        }
    }
    else
    {
    if(0>=x&&0<=y)
        sum=sum+6;
    if(1>=x&&1<=y)
        sum=sum+2;
    if(2>=x&&2<=y)
        sum=sum+5;
    if(3>=x&&3<=y)
        sum=sum+5;
    if(4>=x&&4<=y)
        sum=sum+4;
    if(5>=x&&5<=y)
        sum=sum+5;
    if(6>=x&&6<=y)
        sum=sum+6;
    if(7>=x&&7<=y)
        sum=sum+3;
    if(8>=x&&8<=y)
        sum=sum+7;
    if(9>=x&&9<=y)
        sum=sum+6;
    }
    printf("%llu",sum);
    return 0;
}

#include<stdio.h>
int a[] = {6,2,5,5,4,5,6,3,7,6};
int s(int n)
{
int r = 0;
while(n){r+= a[n%10];n/=10;}
return r;
}
int main()
{
int ans = 0;
int n,m;
scanf("%d%d",&n,&m);
int x;
for(x=n;x<=n;x++)
ans+= s(x);
printf("%d\n",ans);
return 0;
}

#include<stdio.h>
int a[] = {6,2,5,5,4,5,6,3,7,6};
int s(int n)
{
int r = 0;
while(n)r+= a[n/10],n/=10;
return r;
}
int main()
{
int ans = 0;
int n,m;
scanf("%d%d",&n,&m);
int x;
for(x=n;x<=n;x++)
ans+= s(x);
printf("%d\n",ans);
return 0;
}

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>

#define PI 3.141592653589793
#define max(a,b) (a < b) ? (b) : (a)
#define min(a,b) (a > b) ? (b) : (a)
#define FOR(i,a,b) for(i = a ; i <= b ; i++)
#define ROF(i,a,b) for(i = a ; i >= b ; i--)
#define RAD(x) ((x)*PI)/180
#define y1 y_1
#define ll long long
#define endl printf("\n")
#define MAX 100005

int a, b, i, x, ans, t[10] = {6, 2, 5, 5 ,4, 5 ,6, 3, 8, 6};

int main () {
	scanf("%d %d",&a ,&b);
	FOR(i, a, b){
		x = i;
		while(x){
			ans += t[x%10];
			x/=10;
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

//			  0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }
int CoS[] = { 6, 2, 5, 5, 4 ,5, 6, 3, 7, 6 };

int GetCountOfSegment(int a)
{
	int iSum = 0;
	int i = 0;
	int iLen ;

	char strA[20];
	sprintf(strA,"%d",a);

	iLen = strlen( strA );

	for( i = 0 ; i < iLen ; i++ )
	{
		iSum += CoS[ strA[i]-'0' ];
	}

	printf("%d(%s) : %d\n", a, strA , iSum);

	return iSum;
}

int main()
{

	int a,b;
	int iSum = 0;
	int i;

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

	for( i = a ; i <= b ; i++ )
	{
		iSum += GetCountOfSegment( i );

		printf("%d : %d \n\n", i, iSum);

	}

	printf("%d",iSum);

	return 0;
}

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

//			  0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }
int CoS[] = { 6, 2, 5, 5, 4 ,5, 6, 4, 7, 6 };

int GetCountOfSegment(int a)
{
	int iSum = 0;
	int i = 0;
	int iLen ;

	char strA[20];
	sprintf(strA,"%d",a);

	iLen = strlen( strA );

	for( i = 0 ; i < iLen ; i++ )
	{
		iSum += CoS[ strA[i]-'0' ];
	}

	return iSum;
}

int main()
{

	int a,b;
	int iSum = 0;
	int i;

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

	for( i = a ; i <= b ; i++ )
	{
		iSum += GetCountOfSegment( i );
	}

	printf("%d",iSum);

	return 0;
}

#include<stdio.h>
#include<math.h>
#include<string.h>
int number(int a)
{
	int i,num=0;
	do
	{
		i=a%10;
		switch(i)
		{
	 		case 0:num+=6;break;
	 	    case 1:num+=2;break;
	 	    case 2:num+=5;break;
	   	    case 3:num+=5;break;
	     	case 4:num+=4;break;
      		case 5:num+=5;break;
	     	case 6:num+=6;break;
     		case 7:num+=3;break;
       		case 8:num+=7;break;
     		case 9:num+=6;break;
		}
		a/=10;
	}
	while(a/10!=0);
	return num;
}
int main()
{
	int a,b,i,num=0;
	scanf("%d%d",&a,&b);
	for(i=a;i<=b;++i)
	{
		num+=number(i);
	}
	printf("%d",num);
	return 0;
}

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

#define debug(name, arg) printf("debug(%s%d) \n", name, arg)

int solution(int arg, int arg1) {
	int ret = 0;
	int i;
	int rem;
	int number;

	for(i = arg; i <= arg1; ++i) {
		number = i;
		while(number) {
			rem = number % 10;

			switch(rem) {
				case 0 : ret += 6; break;
				case 1 : ret += 2; break;
				case 2 : ret += 5; break;
				case 3 : ret += 5; break;
				case 4 : ret += 4; break;
				case 5 : ret += 5; break;
				case 6 : ret += 6; break;
				case 7 : ret += 3; break;
				case 8 : ret += 7; break;
				case 9 : ret += 9; break;
			}

			number = number / 10;
		}
	}

	return ret;
}

int main()
{
	int a, b;
	int sol;

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

	//debug("a = ",a);
	//debug("b = ",b);

	sol = solution(a, b);
	printf("%d \n", sol);
	//debug("sol = ", sol);

	return 0;
}

#include<stdio.h>
int F(int n){
	switch(n){
		case 0:
			return 6;
		case 1:
			return 2;
		case 2:
			return 5;
		case 3:
			return 5;
		case 4:
			return 4;
		case 5:
			return 5;
		case 6:
			return 6;
		case 7:
			return 3;
		case 8:
			return 7;
		case 9:
			return 6;
	}
}
int main(){
	int a,b,n,m,sum = 0;
	scanf("%d %d",&a,&b);
	for(int i = a; i <= b; i++){
		if(i<10){
			sum += F(i);
		}
		else{
			sum += F(i/10);
			sum += F(i%10);
		}
	}
	printf("%d\n",sum);
	return 0;
}

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

int x[1000];

int main()
{
	memset(x,0,sizeof(x));
	int a,b,n=0;
	scanf("%d %d",&a,&b);
	for ( int i=a;i<=b;i++)
	{
		for ( int j=0;j<=6;j++ )
		{
			x[j] = (i % (int)pow(10,j+1))/ (int)pow(10,j);
		}
		for ( int j=0;j<=6;j++ )
		{
			if ( x[j] == 0 && (x[j+1] !=0 || x[j+2] !=0 || x[j+3] !=0 || x[j+4] !=0 || x[j+5] !=0 || x[j+6] !=0))
			n+=6;
			else
			{
		switch (x[j])
		{
			case 1:
				n+=2;
				break;
			case 2:
				n+=5;
				break;
			case 3:
				n+=5;
				break;
			case 4:
				n+=4;
				break;
			case 5:
				n+=5;
				break;
			case 6:
				n+=6;
				break;
			case 7:
				n+=3;
				break;
			case 8:
				n+=7;
				break;
			case 9:
				n+=6;
				break;
			}
		}
		//printf("%d %d\n",x[j],n);
	}

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

#include<stdio.h>
main(){
	int a,b,c,ans=0;
	scanf("%d %d",&a,&b);
	for(;a<=b;a++){
		c=a;
		for(;c!=0;c=c/10){
			switch(c%10){
				case 0:ans=ans+6;break;
				case 1:ans=ans+2;break;
				case 2:ans=ans+5;break;
				case 3:ans=ans+5;break;
				case 4:ans=ans+4;break;
				case 5:ans=ans+5;break;
				case 6:ans=ans+6;break;
				case 7:ans=ans+3;break;
				case 8:ans=ans+8;break;
				case 9:ans=ans+6;break;
			}
		}
	}
	printf("%d",ans);
}

#include<stdio.h>
main(){
	int a,b,c;
	long long int ans=0;
	scanf("%d %d",&a,&b);
	for(;a<=b;a++){
		c=a;
		for(;c!=0;c=c/10){
			switch(c%10){
				case 0:ans=ans+6;break;
				case 1:ans=ans+2;break;
				case 2:ans=ans+5;break;
				case 3:ans=ans+5;break;
				case 4:ans=ans+4;break;
				case 5:ans=ans+5;break;
				case 6:ans=ans+6;break;
				case 7:ans=ans+3;break;
				case 8:ans=ans+8;break;
				case 9:ans=ans+6;break;
			}
		}
	}
	printf("%d",ans);
}

#include <stdio.h>
#include <math.h>
int count(int n)
{
    int c=0;
    while(n != 0)
    {
    n /= 10;
    ++c;
    }

  return c;
}

int digit(int num,int n)
{   int p, t1, t2;

    t1 = pow(10, n+1);
    p = num % t1;

    if (n > 0)
    {
        t2 = pow(10, n);
        p = p / t2;
    }

    return p;

}
int main()
{

    int x,y,n,i,j,d,z=0;

    scanf("%d %d",&x,&y);
    int hey[10]={6,2,5,5,4,5,6,3,7,6};
    for(i=x;i<=y;i++){
        n=count(i);
        for(j=0;j<n;j++){
        d=digit(i,j);
        z=z+hey[d];

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

}

#include<stdio.h>

int main()
{
	int arr[10]={6,2,5,5,4,5,6,3,7,6};
	int a,b,sum=0,i,rem,temp;
	scanf("%d%d",&a,&b);
	for(i=a;i<=b;i++)
	{
		temp=i;
		while(temp!=0)
		{
			rem=temp%10;
			sum+=arr[rem];
			printf("%d ",sum);
			temp=temp/10;
		}
	}
	printf("%d",sum);
}

#include <stdio.h>

int main()
{
	int svSeg[10]={6,2,5,5,4,5,6,3,7,6};

	int firNum=0,lastNum=0;

	int sum=0;
	scanf("%d%d",&firNum,&lastNum);
	for(int i=firNum ; i <= lastNum ; i++){

		int iCal=i;

		if( iCal/1000000 != 0)
		sum = sum + svSeg[iCal/1000000];
		iCal = iCal % 1000000;

		if( iCal/100000 != 0)
		sum = sum + svSeg[iCal/100000];
		iCal = iCal % 100000;

		if( iCal/10000 != 0)
		sum = sum + svSeg[iCal/10000];
		iCal = iCal % 10000;

		if( iCal/1000 != 0)
		sum = sum + svSeg[iCal/1000];
		iCal = iCal % 1000;

		if( iCal/100 != 0)
		sum = sum + svSeg[iCal/100];
		iCal = iCal % 100;

		if( iCal/10 != 0)
		sum = sum + svSeg[iCal/10];
		iCal = iCal % 10;

		sum = sum + svSeg[iCal];
	}

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

#include<stdio.h>

int yes(int *t,int n)
{
	if(n>=10)
	return t[n%10]+yes(t,n/10);
	else return t[n];
}

int main(){
	int sig[]={4,2,5,5,4,5,6,3,7,6};
	int a,b,i,s=0;
	scanf("%d%d",&a,&b);
	for(i=a;i<=b;i++)
		s=s+yes(sig,i);
		printf("%d",s);
	return 0;
}

#include <stdio.h>

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);

    unsigned long long counts[10];
    for (int i = a; i <= b; i++) {
        int x = i;
        while (x != 0) {
            counts[x % 10]++;
            x /= 10;
        }
    }

    int digits[] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    unsigned long long ans = 0;
    for (int i = 0; i < 10; i++) {
        ans += (unsigned long long)(counts[i] * digits[i]);
    }
    printf("%lld\n", ans);
    return 0;
}

#include<stdio.h>
int main()
{
    long long int sum=0;
    int x,z,y,dif,i,temp;
    scanf("%d %d",&x,&y);
    if(x>=9)
    {
        dif=y-x;
        for(i=0;i<=dif;i++)
        {
            z=x;
            while(z!=0)
            {
            temp=z%10;
    if(0==temp)
        sum=sum+6;
    if(1==temp)
        sum=sum+2;
    if(2==temp)
        sum=sum+5;
    if(3==temp)
        sum=sum+5;
    if(4==temp)
        sum=sum+4;
    if(5==temp)
        sum=sum+5;
    if(6==temp)
        sum=sum+6;
    if(7==temp)
        sum=sum+3;
    if(8==temp)
        sum=sum+7;
    if(9==temp)
        sum=sum+6;
         z=z/10;
        }
        x++;
        }
    }
    else
    {
    if(0>=x&&0<=y)
        sum=sum+6;
    if(1>=x&&1<=y)
        sum=sum+2;
    if(2>=x&&2<=y)
        sum=sum+5;
    if(3>=x&&3<=y)
        sum=sum+5;
    if(4>=x&&4<=y)
        sum=sum+4;
    if(5>=x&&5<=y)
        sum=sum+5;
    if(6>=x&&6<=y)
        sum=sum+6;
    if(7>=x&&7<=y)
        sum=sum+3;
    if(8>=x&&8<=y)
        sum=sum+7;
    if(9>=x&&9<=y)
        sum=sum+6;
    }
    printf("%d",sum);
    return 0;
}

#include<stdio.h>
int main()
{
    long long int sum=0;
    int x,z,y,dif,i,temp;
    scanf("%d %d",&x,&y);
    if(x>=9)
    {
        dif=y-x;
        for(i=0;i<=dif;i++)
        {
            z=x;
            while(z!=0)
            {
            temp=z%10;
    if(0==temp)
        sum=sum+6;
    if(1==temp)
        sum=sum+2;
    if(2==temp)
        sum=sum+5;
    if(3==temp)
        sum=sum+5;
    if(4==temp)
        sum=sum+4;
    if(5==temp)
        sum=sum+5;
    if(6==temp)
        sum=sum+6;
    if(7==temp)
        sum=sum+3;
    if(8==temp)
        sum=sum+7;
    if(9==temp)
        sum=sum+6;
         z=z/10;
        }
        x++;
        }
    }
    else
    {
    if(0>=x&&0<=y)
        sum=sum+6;
    if(1>=x&&1<=y)
        sum=sum+2;
    if(2>=x&&2<=y)
        sum=sum+5;
    if(3>=x&&3<=y)
        sum=sum+5;
    if(4>=x&&4<=y)
        sum=sum+4;
    if(5>=x&&5<=y)
        sum=sum+5;
    if(6>=x&&6<=y)
        sum=sum+6;
    if(7>=x&&7<=y)
        sum=sum+3;
    if(8>=x&&8<=y)
        sum=sum+7;
    if(9>=x&&9<=y)
        sum=sum+6;
    }
    printf("%llu",sum);
    return 0;
}

#include<stdio.h>
int main()
{
    int x,z,y,sum=0,dif,i,temp;
    scanf("%d %d",&x,&y);
    if(x>=9)
    {
        dif=y-x;
        for(i=0;i<=dif;i++)
        {
            z=x;
            while(z!=0)
            {
            temp=z%10;
    if(0==temp)
        sum=sum+6;
    if(1==temp)
        sum=sum+2;
    if(2==temp)
        sum=sum+5;
    if(3==temp)
        sum=sum+5;
    if(4==temp)
        sum=sum+4;
    if(5==temp)
        sum=sum+5;
    if(6==temp)
        sum=sum+6;
    if(7==temp)
        sum=sum+3;
    if(8==temp)
        sum=sum+7;
    if(9==temp)
        sum=sum+6;
         z=z/10;
        }
        x++;
        }
    }
    else
    {
    if(0>=x&&0<=y)
        sum=sum+6;
    if(1>=x&&1<=y)
        sum=sum+2;
    if(2>=x&&2<=y)
        sum=sum+5;
    if(3>=x&&3<=y)
        sum=sum+5;
    if(4>=x&&4<=y)
        sum=sum+4;
    if(5>=x&&5<=y)
        sum=sum+5;
    if(6>=x&&6<=y)
        sum=sum+6;
    if(7>=x&&7<=y)
        sum=sum+3;
    if(8>=x&&8<=y)
        sum=sum+7;
    if(9>=x&&9<=y)
        sum=sum+6;
    }
    printf("%d",sum);
    return 0;
}

#include<stdio.h>
int main()
{
    int x,z,y,sum=0,dif,i,temp;
    scanf("%d %d",&x,&y);
    if(x>9)
    {
        dif=y-x;
        for(i=0;i<=dif;i++)
        {
            z=x;
            while(z!=0)
            {
            temp=z%10;
    if(0==temp)
        sum=sum+6;
    if(1==temp)
        sum=sum+2;
    if(2==temp)
        sum=sum+5;
    if(3==temp)
        sum=sum+5;
    if(4==temp)
        sum=sum+4;
    if(5==temp)
        sum=sum+5;
    if(6==temp)
        sum=sum+6;
    if(7==temp)
        sum=sum+3;
    if(8==temp)
        sum=sum+7;
    if(9==temp)
        sum=sum+6;
         z=z/10;
        }
        x++;
        }
    }
    else
    {
    if(0>=x&&0<=y)
        sum=sum+6;
    if(1>=x&&1<=y)
        sum=sum+2;
    if(2>=x&&2<=y)
        sum=sum+5;
    if(3>=x&&3<=y)
        sum=sum+5;
    if(4>=x&&4<=y)
        sum=sum+4;
    if(5>=x&&5<=y)
        sum=sum+5;
    if(6>=x&&6<=y)
        sum=sum+6;
    if(7>=x&&7<=y)
        sum=sum+3;
    if(8>=x&&8<=y)
        sum=sum+7;
    if(9>=x&&9<=y)
        sum=sum+6;
    }
    printf("%d",sum);
    return 0;
}

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

//1〜nに含まれるcountの個数を求める
unsigned long long solve(unsigned long long n,int count,int base){
	unsigned long long r=0; //結果
	unsigned long long lower=0; //処理している桁より下の桁の合計
	unsigned long long digits=0,expbase=1;
	for(;n;digits++,expbase*=base,n/=base){
		unsigned long long d=digits*expbase/base; //0,1,20,300,4000,...
		unsigned long long current_digit=n%base;
		r+=current_digit*d;
		if(current_digit==count)r+=lower+1;
		if(current_digit>=count+1)r+=expbase;
		lower+=current_digit*expbase;
		if(count==0)r-=expbase;
	}
	return r;
}

int d[]={6,2,5,5,4,5,6,3,7,6};
int main(int argc,char **argv){
	int base=10;

	unsigned long long n,m,r=0;
	//%d is used due to lovely msvcrt.
	scanf("%d%d",&n,&m);
	int i=0;
	for(;i<10;i++)r+=d[i]*(solve(m,i,base)-solve(n-1,i,base));
	printf("%d\n",r);
}

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

int main()
{ int a,b,c=0,i,d,e;
printf("a= ");scanf("%d",&a);
printf("b= ");scanf("%d",&b);
for(i=a;i<=b;i++)
    {d=i;
    while (d!=0)
        {e=d%10; d=d/10;
    switch(e)
    { case 0: {c+=6; break;}
      case 1: {c+=2; break;}
      case 2: {c+=5; break;}
      case 3: {c+=5; break;}
      case 4: {c+=4; break;}
      case 5: {c+=5; break;}
      case 6: {c+=6; break;}
      case 7: {c+=3; break;}
      case 8: {c+=7; break;}
      case 9: {c+=6; break;}
    }}}

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

#include<stdio.h>
int a[]={6,2,5,5,4,5,6,3,7,6};
int cnt(int n)
{
    if(n==0)
        return;
    return a[n%10]+(n/10);
}
int main()
{
    int a,b;
    long long s=0;
    scanf("%d%d",&a,&b);
    for(int i=a;i<=b;i++)
    {
        int t=i;
        s+=cnt(t);
    }
    printf("%lld\n",s);
    return 0;
}

#include <stdio.h>
long long min(long long a, long long b){
    return a>b?b:a;
}
long long max(long long a, long long b){
    return a<b?b:a;
}
int cnt[]={6,2,5,5,4,5,6,3,0,6};
long long slv(long long n){
    long long s=0;
    while(n){
        s+=cnt[n%10];
        n/=10;
    }
    return s;
}
int main(){
    int a,b,i; long long ans=0;
    scanf("%d%d",&a,&b);
    for(i=a;i<=b;++i){
        ans+=slv(i);
    }
    printf("%lld\n",ans);
    return 0 ;
}

#include <stdio.h>
int ara[12];
long long visited[1000010];
int main()
{
    long long a,b,c,d,k,r,i;
     ara[0]=6;
     ara[1]=2;
     ara[2]=5;
     ara[3]=5;
     ara[4]=4;
    ara[5]=5;
    ara[6]=6;
    ara[7]=7;
    ara[8]=7;
    ara[9]=6;
    visited[0]=6;
    long long sum=6;
    for(i=1;i<=1000000;i++){
        a=i;
        while(a!=0){
            sum=sum+ara[a%10];
            a=a/10;
        }
      visited[i]=sum;
    }
  scanf("%I64d%I64d",&a,&b);
    printf("%I64d\n",visited[b]-visited[a-1]);
}

#include <stdio.h>

int segCalc(int number){
	if(number==4){
		return 4;
	}else if (number==1){
		return 2;
	}else if (number==2||number==5||number==3){
		return 5;
	}else if (number==6||number==0){
		return 6;
	}else if (number==7){
		return 3;
	}else if (number==8){
		return 8;
	}else if (number==9){
		return 7;
	}

}
long findSeg(long i){
	long seg;
	int temp;
	if(i/10==0){
		seg= segCalc(i);
		return seg;
	}
	else{
		temp=i%10;
		seg=segCalc(temp);

		return seg+findSeg(i/10);
	}

}
int main() {
	// your code goes here
	long a,b,sum=0,i;

	scanf("%ld %ld",&a,&b);
	for(i=a;i<=b;i++){

	sum+=	findSeg(i);

	}
	printf("%ld",sum);
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
int main()
{
    int clock[10]={6,2,5,5,4,5,6,3,7,6};
    int sta,fin,ans;
    scanf("%d%d",&sta,&fin);
    for(int i=sta;i<=fin;i++)
    {
        int a=i;
        while(a/10>0)
        {
            ans+=clock[a%10];
            a/=10;
        }
        ans+=clock[a];
    }
    printf("%d\n",ans);
    return 0;
}

#include<stdio.h>
int a[]={6,2,5,5,4,5,6,3,7,6};
int cnt(int n)
{
    if(n==0)
        return;
    return (a[n%10]+cnt(n/10));
}
int main()
{
    int a,b;
    long long s=0;
    scanf("%d%d",&a,&b);
    for(int i=a;i<=b;i++)
    {
        int t=i;
        s+=cnt(t);
    }
    printf("%lld\n",s);
    return 0;
}

#include<stdio.h>
int a[]={6,2,5,5,4,5,6,3,7,6};
int cnt(int n)
{
    if(n==0)
        return;
    return a[n%10]+cnt(n/10);
}
int main()
{
    int a,b;
    long long s=0;
    scanf("%d%d",&a,&b);
    for(int i=a;i<=b;i++)
    {
        int t=i;
        s+=cnt(t);
    }
    printf("%lld\n",s);
    return 0;
}

#include<stdio.h>
int a[]={6,2,5,5,4,5,6,3,7,6};
int cnt(int n)
{
    int s=0;
    if(n==0)
        return;
    s=a[n%10]+cnt(n/10);
    return s;
}
int main()
{
    int a,b;
    long long s=0;
    scanf("%d%d",&a,&b);
    for(int i=a;i<=b;i++)
    {
        int t=i;
        s+=cnt(t);
    }
    printf("%lld\n",s);
    return 0;
}


#include <stdio.h>

int main(void) {
	// your code goes here

    int n,amax,bmax,cmax,i,j,k,flag=0;

    scanf("%d",&n);

    amax = n/1234567;

    for(i=0;i<=amax;i++)
    {
        if(i*1234567 > n)
            break;

        bmax = n-i*1234567;

        for(j=0;j<=bmax;j++)
        {
            if(i*1234567 + 123456*j > n)
                break;

            cmax = n-i*1234567-j*123456;

            if(cmax%1234 == 0)
                flag = 1;
        }
    }

    if(flag==0)
        printf("NO");
    else
        printf("YES");

    return 0;
}

#include<stdio.h>
int main()
{
    int a=1234567,b=123456,c=1234,sum,n,flag=0,i,j,m;
    scanf("%d",&n);
    sum=n;
    if(n%a==0 || n%b==0 || n%c==0) printf("YES\n");
    else{
    for(i=0; flag==0 ;i++)
    {
        sum=n;
        sum=sum-i*a;
        m=sum;
        if(sum<0) break;

        for(j=0; flag==0 ; j++)
        {   //printf("i= %d  j=%d\n",i,j);
            sum=m;
            sum=sum-j*b;
            if(sum<0) break;

            if(sum%c==0) { flag=1; printf("YES\n"); }
            //printf("%d %d\n",sum,sum%c);
        }
    }
    //printf("%d %d\n",i,j);
    if(flag==0) printf("NO\n");
    }

    return 0;
}

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

int main()
{
   int n,i,j;
   long int r ;
   int flag =0 ;
   scanf("%d",&n);
for (i=0 ; i<=(n/1234567) ; i++)
{

    for (j=0 ; j<=(n/123456) ; j++)
        {
    r=n-i*1234567-j*123456;
    if(r>=0 && r%1234 == 0 ){
        printf("YES");
        flag =1;
        break;
    }
}
if (flag)
break;
}
if (flag == 0 )
printf("NO");
    return 0;
}

#include <stdio.h>

int main()
{
    int N;
    scanf("%d", &N);
    for(int i = 0; i < 100; ++i) {
        for(int j = 0; j < 1000; ++j) {
            int remain = N - i * 1234567 - j * 123456;
            if(remain >= 0 && remain % 1234 == 0) {
                puts("YES");
                return 0;
            }
        }
    }
    puts("NO");
    return 0;
}

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

int main () {
long long int n;
long long int house = 1234567;
long long int car = 123456;
long long int computer = 1234;
scanf("%lld",&n);
long long int sum = n;

for (int i=0;i<n+1;i = i + house)
	for (int j=0; j<=n-i;j=j+car) {
		if ((n-i - j)%1234==0){
			printf("YES\n");
			return 0;
		}
	}

printf("NO\n");

return 0;
}

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

#define HOUSE    (1234567)
#define CAR      (123456)
#define COMPUTER (1234)

int main() {
  bool ok = false;
  int n,nh,ncr,i,j;

  scanf("%d", &n);
  for ( nh = n / HOUSE, i=0; i <= nh; ++i )
    for ( ncr = (n-i*HOUSE) / CAR, j=0; j <= ncr; ++j )
      if ( (n - i*HOUSE - j*CAR) % COMPUTER == 0 )
        ok = true;
  printf("%s\n", ok ? "YES" : "NO");
  return EXIT_SUCCESS;
}

#include<stdio.h>
int main()
{
	long int n;
	scanf("%ld",&n);
	int i,j;
	for(i=0;i<=n;i+=1234567)
	{
		for(j=0;j<=n-i;j+=123456)
			if((n-i-j)%1234==0)
			{
				printf("YES\n");
				return 0;
			}
	}
	printf("NO\n");
	return 0;
}

#include <stdio.h>
const int a=1234567;
const int b=123456;
const int c=1234;
int main()
{
	int n,i,j,k;
	scanf("%i",&n);
	for(i=0;i<(n/a+1);i++)
		for(j=0;j<(n/b+1);j++){
			k=n-a*i-b*j;
			if(!(k%1234||k<0)){
				puts("YES");
				return 0;
			}
		}
	puts("NO");
	return 0;
}

#include <stdio.h>
const int a=1234567;
const int b=123456;
const int c=1234;
int n;
int main()
{
    scanf("%d",&n);
    for (int i=0;i<=n/a;i++)
        for (int j=0;j<=(n-i*a)/b;j++)
    {
        if ((n-i*a-j*b)%c==0)
        {
            printf("YES");
            return 0;
        }
    }
    printf("NO");
    return 0;
}

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

int main()
{long long int n;
    scanf("%lld",&n);
for(long long int i=0;i<=n;i+=1234567)
{for(long long int j=0;j<=(n-i);j+=123456)
{if((n-i-j)%(1234)==0)
{printf("YES");
exit(0);}

}}
printf("NO");

return 0;}

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

int main()
{
   int64_t n, t;
   scanf("%I64d", &n);

   do
   {
      t = n;
      do
      {
         if(t % 1234 == 0)
         {
            printf("YES\n");
            return 0;
         }
         t -= 123456;
      }
      while(t >= 0);

      n -= 1234567;
   }
   while(n >= 0);

   printf("NO\n");
   return 0;
}

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

#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

int main(){
    int flag;
    long long n, a, b, c, x, y, z, r, i, j, k;

    while (scanf("%lld", &n) != EOF){
        flag = 0;
        x = 1234567, y = 123456, z = 1234;

        for (a = 0; (a * x) <= n; a++){
            for (b = 0; ((a * x) + (b * y)) <= n; b++){
                r = n - (a * x) - (b * y);
                if ((r % z) == 0) flag = 1;
            }
        }

        if (flag) puts("YES");
        else puts("NO");
    }
    return 0;
}

#include <stdio.h>

int main(void) {

	int n,flag=0;
	long long i=0;

	scanf("%d ",&n);

	while(i*1234567<=n)
	{
		long long j=0;

		while(i*1234567+j*123456<=n)
		{
			if((n-i*1234567-j*123456)%1234==0) flag=1;
			j++;
		}

		i++;
	}

	if(flag) printf("YES\n");
		else printf("NO\n");
	return 0;
}

#include <stdio.h>

int hcf(long int n1,long int n2)
{
    if (n2!=0)
       return hcf(n2, n1%n2);
    else
       return n1;
}
int main(void) {
	long int n,i,j,a,b,flag=0;
	scanf("%ld",&n);
	a=811;
	b=8101;
	for(i=0;i<=811;i++)
	{
	    for(j=0;j<=8101;j++)
	    {
	        if((n-i*1234567-j*123456)<0)
	        break;
	        if((n-i*1234567-j*123456)%1234==0)
	        {
	            flag=1;
	            break;
	        }
	    }
	    if(flag==1)
	    break;
	}
	if(flag==1)
	printf("YES");
	else
	printf("NO");
	return 0;
}

#include <stdio.h>

int main()
{
    int n;
    int i;
    int j;
    scanf("%d",&n);
    for(i=0;i<=n;i=i+1234567)
    {
        for(j=0;j<=n-i;j=j+123456)
        {
            if((n-i-j)%1234 == 0)
            {
                printf("YES");
                return 0;
            }
        }
    }
    printf("NO");
    return 0;
}

#include<stdio.h>
#include<string.h>
#include<limits.h>
#include<stdlib.h>
#include<ctype.h>
#include<math.h>
char arr[2500];

int main(){
	long long a,b,c,d,e; int flag =0;
	long long input; scanf("%lld",&input);
	for(a=0;a<=8200;a++){
		for(b=0;b<=8200;b++){
			int res = (input - ((a*1234567)+(b*123456)) );
			if( (res % 1234 )==0 && (((res/1234)*1234) + a*1234567 + b*123456) == input && res/1234 >=0 ){
				//printf("%lld %lld %lld --%lld %lld\n",a,b,(input - ((a*1234567)+(b*123456)) ) ,a,b );
				printf("YES");
				return 0;
			}
		}
	}
	printf("NO");
}

#include <stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    int n2 = n+1;
    int ans = 0;
    for(;n2 > 0;n2 -= 1234567)
    {
        int n3 = n2;
        for(;n3 > 0;n3 -= 123456)
        {
            if(n3 % 1234 == 1)
            {
                ans = 1;
                goto mark;
            }
        }
    }
mark:if(ans == 1)
        printf("YES");
     else
        printf("NO");
    return 0;
}

#include <stdio.h>

int n, x, y, z, r;

void input();
int solve();
void output();

int GCD(int a, int b) {
	if (!b) return a;
	else return GCD(b, a%b);
}

int main() {
	input();
	output();
}

void input() {
	scanf("%d", &n);
}

int solve() {
	x = n / 1234567;
	y = n / 123456;

	for(int i=0; i<=x; i++)
		for (int j = 0; j <= y; j++)
			if (n - i * 1234567 - j * 123456 >= 0 && (n - i * 1234567 - j * 123456) % 1234 == 0)
				return 1;

	return 0;
}

void output() {
	if (solve()) printf("YES\n");
	else printf("NO\n");
}

#include<stdio.h>
#include<stdlib.h>
typedef unsigned u;
u ok;
void H(u n)
{
	if(n%1234==0)ok=1;
	return;
}
void G(u n)
{
	u x=123456;
	n+=x;
	do
	{
		if(n>=x)n-=x;
		H(n);
	}
	while(n>=x);
	return;
}
void F(u n)
{
	u x=1234567;
	n+=x;
	do
	{
		if(n>=x)n-=x;
		G(n);
	}
	while(n>=x);
	return;
}
int main()
{
	u n;
	scanf("%u",&n);
	F(n);
	printf(ok?"YES\n":"NO\n");
	return 0;
}

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

int main()
{
    long long int sum, a, b;
    scanf("%I64d", &sum);
    for (a = 0; a <= sum/1234567; a++){
        for (b = 0; b <= sum/123456; b++){
            long long int x = (sum - a*1234567 - b*123456);
            if ((x >= 0) && (x % 1234 == 0)){
                printf("YES\n"); return 0;
            }
        }
    }
    printf("NO\n");
    return 0;
}

#include <stdio.h>
int main()
{
	int ch=0;
    long long int a=1234567;
    long long int b=123456;
    long long int c=1234;
    long long int i,j;
    long long int n;
    scanf("%I64d",&n);
    for(i=0;i<=1000;i++)
        for(j=0;j<=10000;j++)
        {
            long long int temp=n-a*i-b*j;
            if(temp%1234==0 && temp>=0)
            {
                ch=1;
            }
        }
    if(ch) printf("YES\n");
    else printf("NO\n");
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main()
{
	long int n,a,b;
	scanf("%ld",&n);
	for(a=0;a<=n;a+=1234567)
		for(b=0;b<=n-a;b+=123456)
			if((n-a-b)%1234==0){
				printf("YES\n");
				return 0;
			}
	printf("NO\n");
	return 0;
}

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

//681B Economy Game.
main()
{
    int n,i,j,flag=0;
    scanf("%d",&n);
    int house=1234567,car=123456,computer=1234;

    int x=n/house;
    int clone=n,c_copy=0;

    for(i=x; house*i>=0;i--)
    {
        clone=n-house*i;
        for(j=0;j*car<=clone;j++)
            {
                c_copy=clone-car*j;
                if(c_copy%computer==0)
                {
                    flag=1;
                    break;
                }
            }

    }
    if(flag) printf("YES\n");
    else printf("NO\n");
    return 0;
}

#include<stdio.h>

int main() {

    int n; scanf("%d",&n);
    int i=0,j=0;
    int rest = n, flag = 0;
    for(i=0; i*1234567<=n;i++)
    {
        rest = n -  i * 1234567;
        for(j=0;j*123456<=rest;j++)
        {
            if( (rest - j*123456)%1234==0) {
                flag=1 ;//Yes
                break;
            }

        }

    }
    if(flag) printf("YES\n");
    else printf("NO\n");
    return 0;
}

#include<stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    for(int a=0;a<=n;a+=1234567)
    {
        for(int b = 0;b<=n-a;b+=123456)
        {
            if((n-a-b)%1234==0)
            {
                printf("YES\n");
                return 0;
            }
        }
    }printf("NO\n");
    return 0;
}

#include<stdio.h>

	int main()
	{
		long long int n;
		long long int i,j,z;
		long long int flag = 0;
		scanf("%lld",&n);

		   for(i=0;i< 100000001; i = i + 1234567 )
		       {
				 for(j=i;j< 100000001; j = j + 123456 )
        				 {

						if(n>=j){

						 long long int temp = n-j;
		              	//printf("%d\n",temp);
				        if(temp%1234 == 0)
		                    flag = 1;
				    }

			}
			  if(flag == 1)
			    break;
			}

		if(flag == 1)
		 printf("YES");
		else
		 printf("NO");

		 return 0;
	}

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
	int a;
	scanf("%d", &a);
	for (int i = 0; i <= a; i += 1234567) {
		for (int j = 0; j <= a - i; j += 123456) {
			if ((a - i - j) % 1234 == 0) {
				printf("YES");
				return 0;
			}
		}
	}
	printf("NO");
	return 0;
}
/* Mon Dec 30 2019 01:14:18 GMT+0300 (MSK) */

#include <stdio.h>

int main()
{
	long long n,i,j;
	scanf("%lld",&n);
	for(i=0;i<=n;i+=1234567)
	for(j=0;j<=n-i;j+=123456)
	if((n-i-j)%1234==0)
	{
		printf("YES\n");
		return 0;
	}

	printf("NO\n");

	return 0;
}

#include <stdio.h>
const int House = 1234567;
const int Car = 123456;
const int Computer = 1234;
int main()
{
#ifdef LOCAL
	freopen("test.txt", "r", stdin);
#endif
    int n;
    scanf("%d", &n);
    int a = n / House;
    for(int i = 0; i <= a; i++)
    {
        int b = (n - i * House) / Car;
        for(int j = 0; j <= b; j++)
        {
            int c = n - (i * House + j * Car);
            if(c >= 0 && c % Computer == 0)
            {
                puts("YES");
                return 0;
            }
        }
    }
    puts("NO");
}

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

int main()
{
    long long int i,a,b,j,y,x,m,cur=0,n,t,c1,c2,n1,n2,m1,m2,te,tem,temp;

    long long int sum=0,max=0,ans=0,tl=1,k,w=0,on=0,z=0,wh=0;

        scanf("%lld",&n);
       a=n/1234567;
       b=n/123456;
        for(i=0;i<=a;i++)
            for(j=0;j<=b;j++)
                {
                    te=n-(i*1234567+j*123456);
                    if(te%1234==0&&te>-1)
                    w=1;

                }
        if(w)
            printf("YES\n");
        else
            printf("NO\n");

    return 0;
}

#include <stdio.h>

int main(void) {
	long long int n,i,j,k;
	int c=0;
	scanf("%lld",&n);
	for(i=0;i<=n;i=i+1234567)
	 { //printf("i=%lld",i);
	     for(j=0;j<=n;j=j+123456)
	  {//printf("j=%lld",j);
	      k=n-i-j;
	     //k=k/1234;
	   //printf("k=%lld\n",k);
	     if(k>=0&&k%1234==0)
	     {//printf("YES");
	       c=1;
	         break;
	     }
	  }
	  }
	  //printf("c=%d",c);
	  if(c==1)
	    printf("YES");
	   else
	     printf("NO");
	return 0;
}

#include <stdio.h>

int main()
{
    long long int a,b,c,n,i,j,flag;
    a = 1234567;
    b = 123456;
    c = 1234;

    while(scanf("%I64d",&n) == 1)
    {
        flag = 0;
        for(i=0;i<=n;i+=a)
        {
            for(j=0;j<=n-i;j+=b)
            {
                if((n-(i+j))%c == 0)
                {
                    printf("YES\n");
                    flag = 1;
                    break;
                }
            }
            if(flag == 1)
                break;
        }
        if(flag == 0)
            printf("NO\n");
    }
    return 0;
}

#include<stdio.h>

#define ll long long

int main()
{
    //freopen("in.txt", "r", stdin);

    ll a=1234567, b = 123456, c= 1234;

    ll n, ans, ans2, i, j;
    int flag = 0;

    scanf("%I64d", &n);

    if(n%a == 0 || n%b==0 || n%c == 0) flag = 1;

    ans = 0;

    for(i=1; flag == 0 && ans<=n ; i++) {

        ans2 = ans;

        if( ans2>0 && n%ans2 == 0) flag = 1;

        for(j=1; ans2 <= n && flag == 0 ; j++){

            if( ( n-ans2 ) % c == 0) {
                flag = 1;
                break;
            }

            ans2 = ans + j*b;
            if(n%ans2 == 0) flag = 1;
        }

        ans = i*a;
        if(n%ans==0) flag = 1;
    }

    if(flag == 1) printf("YES\n");
    else printf("NO\n");
}

#include <stdio.h>
 //Compiler version gcc 6.3.0

 int main(void)
 {
 	int n;
 	scanf("%d", &n);
 	int l1=n/1234567, l2=n/123456;
 	for(int i=0;i<=l1;i++) {
 		for(int j=0; j<=l2; j++) {
 			int s=i*1234567+j*123456;
 			if(s>n) break;
 			if((n-s)%1234==0) {
 				printf("YES");
 				return 0;
 			}
 		}
 	}
 	printf("NO");
 	return 0;
 }

#include<stdio.h>

int main()
{
    long long int n;
    long long int i,j,k,a,b,c;
    a=1234567;
    b=123456;
    c=1234;
    int flag=0;
    long long int p;
    scanf("%lld",&n);
    for(i=0;;i++)
    {
        if(i*a>n){break;}
        for(j=0;;j++)
        {
            p=i*a+j*b;
            if(i*a+j*b>n){break;}
            if((n-p)%c==0){flag=1;break;}
        }
    }

    if(flag==1){printf("YES");}
    else printf("NO");

    return 0;
}

#include <stdio.h>
int main()
{
    //printf("Hello World!\n");
    long long int n, a, b;
    scanf("%lld", &n);
    for(a=0; a<=n; a+=1234567)
    {
        for(b=0; b<=n-a; b+=123456)
        {
            if((n-a-b)%1234==0)
            {
                printf("YES");
                return 0;
            }
        }
    }
    printf("NO");
    return 0;
}

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

#define SET(a,b) memset(a,b,sizeof(a))
#define scan(n) scanf("%d",&n)
#define print(n) printf("%d\n",n)
#define scanl(n) scanf("%lld",&n)
#define printl(n) printf("%lld\n",n)

//stacks
/*void push(int n,int ar[],int i)
{
        ar[i]=n;
        i++;
}
void pop(int ar[],int i)
{
        if(i>0)
        {
                ar[i-1]=0;
                i--;
        }
}*/

//queues
/*void qpush(int ar[],int val,int head,int tail,int range)
{
        if(head==tail)
        {
                ar[head]=val;
                if(tail+1==range)
                        tail=0;
                else
                        tail++;
        }
        else
        {
                ar[tail]=val;
                if(tail+1==range)
                        tail=0;
                else
                        tail++;
        }
        if(tail==head)
        {
                if(head+1==range)
                        head=0;
                else
                        head++;
        }
}

void qpop(int head,int tail,int range)
{
        if(head+1==range)
                head=0;
        else
                head++;
}*/

//pow
/*int fun(int a,int b,int m)
{
        if(b==0)
                return 1;
        int d,x;
        d=fun(a,b/2,m);
        x=(d*d)%m;
        if(b%2==0)
                return x;
        else
                return (x*a%m)%m;
}
*/
//bst
/*typedef struct tree
{
        int val;
        struct tree *l;
        struct tree *r;
}node;
//node *head;
node *insert(int x,node *root)
{
        if(root==NULL)
        {
                root=(node *)malloc(sizeof(node));
                root->val=x;
        }
        else
        {
                if(x<=root->val)
                {
                        if(root->l==NULL)
                        {
                                root->l=(node *)malloc(sizeof(node));
                                root->l->val=x;
                        }
                        else
                                root->l=insert(x,root->l);
                }
                else
                {
                        if(root->r==NULL)
                        {
                                root->r=(node *)malloc(sizeof(node));
                                root->r->val=x;
                        }
                        else
                        {
                                root->r=insert(x,root->r);
                        }
                }
        }
        return root;
}
node *find(int x,node *root)
{
        if(root==NULL)
        {
                return 0;
        }
        else
        {
                if(x==root->val)
                        return root;
                else if(x<root->val)
                {
                        if(root->l==NULL)
                        {
                                return 0;
                        }
                        else
                        {
                                find(x,root->l);
                        }
                }
                else
                {
                        if(root->r==NULL)
                        {
                                return 0;
                        }
                        else
                        {
                                find(x,root->r);
                        }
                }
        }
}

void inorder(node *root)
{
        if(root==NULL)
        {
                return;
        }
        if(root->l==NULL)
        {
                printf("%d",root->val);
                if(root->r==NULL)
                        return;
                else
                        inorder(root->r);
        }
        else
        {
                inorder(root->l);
                printf("%d",root->val);
                if(root->r==NULL)
                        return;
                else
                        inorder(root->r);
        }
}
void preorder(node *root)
{
        if(root==NULL)
        {
                return;
        }
        else
        {
                printf("%d",root->val);
                preorder(root->l);
                preorder(root->r);
        }
}

void postorder(node *root)
{
        if(root==NULL)
        {
                return;
        }
        else
        {
                postorder(root->l);
                postorder(root->r);
                printf("%d",root->val);
        }
}
*/
//adjacency list
/*typedef struct ll
{
        int val;
        struct ll *next;
}nd;

//n *ar[100001];
void insert(int a,int b)
{
        if(ar[a]==NULL)
        {
                ar[a]=(nd *)malloc(sizeof(nd));
                ar[a]->val=b;
                ar[a]->next=NULL;
        }
        else
        {
                nd *temp=(nd *)malloc(sizeof(nd)),*t;
                temp->val=b;
                temp->next=ar[a];
                ar[a]=temp;
        }
}

//dfs
//int state[100001];
void dfs(int a)
{
        state[a]=1;
        count++;
        nd *temp=ar[a];
        while(temp!=NULL)
        {
                if(state[temp->val]!=1)
                        dfs(temp->val);
                temp=temp->next;
        }
        return;
}*/

//dijkstra + heaps
/*typedef struct ll2
{
        int val;
        int weight;
        struct ll2 *next;
}nde;
*/
//nde *ar[500005];
//int state[500005];

/*void insert(int a,int b,int w)//insert to adjacency list
{
	if(ar[a]==NULL)
  	{
 	 	ar[a]=(node *)malloc(sizeof(node));
 	 	ar[a]->val=b;
 	 	ar[a]->weight=w;
 	 	ar[a]->next=NULL;
 	}
 	else
  	{
  		node *temp=(node *)malloc(sizeof(node)),*t;
  		temp->val=b;
  		temp->weight=w;
  		temp->next=ar[a];
  		ar[a]=temp;
  	}
}*/

//int pt[500005],d[500005];
//int heap[500005][2];
//int ptr;
/*void decpty(int val,int pos)//decrease priority
{
        heap[pos][0]=val;
        int x=pos;
        while(x>0)
        {
                if(heap[x][0]>=heap[x/2][0])
                        break;
                else
                {
                        pt[heap[x][1]]=x/2;
                        pt[heap[x/2][1]]=x;
                        int temp=heap[x][0],t2=heap[x][1];
                        heap[x][0]=heap[x/2][0];
                        heap[x][1]=heap[x/2][1];
                        heap[x/2][0]=temp;
                        heap[x/2][1]=t2;
                        x=x/2;
                }
        }
}

void hinsert(int val,int val2)//insert to heap
{
        heap[ptr][0]=val;
        heap[ptr][1]=val2;
        pt[val2]=ptr;
        int x=ptr;
        ptr++;
        while(x>0)
        {
                if(heap[x][0]>=heap[x/2][0])
                        break;
                else
                {
                        pt[heap[x][1]]=x/2;
                        pt[heap[x/2][1]]=x;
                        int temp=heap[x][0],t2=heap[x][1];
                        heap[x][0]=heap[x/2][0];
                        heap[x][1]=heap[x/2][1];
                        heap[x/2][0]=temp;
                        heap[x/2][1]=t2;
                        x=x/2;
                }
        }
}

int hdeletemin()//delete min elem from heap
{
        int ret;
        ret=heap[1][1];
        pt[heap[1][1]]=-1;
        pt[heap[ptr-1][1]]=1;
        heap[1][0]=heap[ptr-1][0];
        heap[1][1]=heap[ptr-1][1];
        ptr--;
        int x=1;
        while(x<ptr)
        {
                if(2*x+1>=ptr)
                {
                        if(2*x<ptr)
                        {
                                if(heap[2*x][0]<heap[x][0])
                                {
                                        pt[heap[x][1]]=2*x;
                                        pt[heap[2*x][1]]=x;
                                        int temp=heap[x][0];
                                        int temp2=heap[x][1];
                                        heap[x][0]=heap[2*x][0];
                                        heap[x][1]=heap[2*x][1];
                                        heap[2*x][0]=temp;
                                        heap[2*x][1]=temp2;
                                        x=2*x;
                                }
                                else
                                        break;
                        }
                        else
                                break;
                }
                else if(heap[x][0]<=heap[2*x][0] && heap[x][0]<=heap[2*x+1][0])
                        break;
                else
                {
                        if(heap[2*x][0]<=heap[2*x+1][0])
                        {
                                pt[heap[x][1]]=2*x;
                                pt[heap[2*x][1]]=x;
                                int temp=heap[x][0];
                                int temp2=heap[x][1];
                                heap[x][0]=heap[2*x][0];
                                heap[x][1]=heap[2*x][1];
                                heap[2*x][0]=temp;
                                heap[2*x][1]=temp2;
                                x=2*x;
                        }
                        else
                        {
                                pt[heap[x][1]]=2*x+1;
                                pt[heap[2*x+1][1]]=x;
                                int temp=heap[x][0];
                                int temp2=heap[x][1];
                                heap[x][0]=heap[2*x+1][0];
                                heap[x][1]=heap[2*x+1][1];
                                heap[2*x+1][0]=temp;
                                heap[2*x+1][1]=temp2;
                                x=2*x+1;
                        }
                }
        }
        return ret;
}

void dikstra(int u,int v)
{
        while(ptr!=1)
        {
                int v=hdeletemin();
                node *temp=ar[v];
                while(temp!=NULL)
                {
                        int w=temp->val;
                        if(d[v]+temp->weight < d[w])
                        {
                                d[w]=d[v]+temp->weight;
                                decpty(d[w],pt[w]);
                        }
                        temp=temp->next;
                }
        }
}*/

/*int main()
{
  	int n,m,u,v,w,i;
  	scanf("%d%d",&n,&m);
  	for(i=0;i<=n;i++)
  	state[i]=0;
  	while(m--)
  	{
  		scanf("%d%d%d",&u,&v,&w);
  		insert(u,v,w);
  	}
  	scanf("%d%d",&u,&v);
  	ptr=1;
  	hinsert(0,u);
  	d[u]=0;
  	for(i=1;i<=n;i++)
  	{
  		if(i!=u)
  		{
  			hinsert(1000000000,i);
  			d[i]=1000000000;
  		}
  	}
  	dikstra(u,v);
  	if(d[v]==1000000000)
  	printf("NO\n");
  	else
  	printf("%d\n",d[v]);
  	return 0;
}*/

//kruskal + dsu

//int dsu[N];
/*int find(int x)
{
        if(dsu[x]==x)return x;
        return dsu[x] = find(dsu[x]);
}

void Union(int a,int b)
{
        if(a==b)
                return;
        dsu[a] = b;
}

typedef struct edge
{
        int u,v;
        int weight;
}edge;
*/
//edge e[N];
/*int cmp(const void *a,const void *b)
{
	return ((edge*)a)->weight - ((edge*)b)->weight;
}*/
/*int main()
{
  	int i;
  	int n,m;
  	scanf("%d %d\n",&n,&m);
  	for(i=0;i<m;i++)
	scanf("%d %d %d",&e[i].u,&e[i].v,&e[i].weight);
	for(i=1;i<=n;i++)
	dsu[i]=i;
	qsort(e,m,sizeof(edge),cmp);
	long long int sum=0;
	for(i=0;i<m;i++)
	{
	 	int a,b;
	 	if((a=find(e[i].u))!=(b=find(e[i].v)))
	 	{
	 		sum+=e[i].weight;
	  		Union(a,b);
	  	}
	}
	printf("%lld\n",sum);
	return 0;
}*/

//max
/*int max(int a,int b)
{
    if(a>b)
        return a;
    else
        return b;
}
*/
//qsort

/*int cmpfunc(const void *a,const void *b)
{
        return (*(int *)a - *(int *)b);
}*/
//qsort(ar,n,sizeof(int),cmpfunc);

//-------------------------------------------------------------------------------------------------------------------------------------

int main()
{
       int n,ans=0;
       scan(n);
       if(n/1234567>=1)
       {
              n=n%1234567;
              if(n/123456>0)
              {
                     n=n%123456;
                     if(n/1234>0)
                     {
                            n=n%1234;
                            if(n==0)
                            {
                                   printf("YES\n");
                                   return 0;
                            }
                     }
              }
       }
       printf("NO\n");
       return 0;
}

#include <stdio.h>
#include <string.h>
/*int count( long long int S[], int m, long long int n )
{
    if (n == 0)
        return 1;
    if (n < 0)
        return 0;
    if (m <=0 && n >= 1)
        return 0;
    return count( S, m - 1, n ) + count( S, m, n-S[m-1] );
}*?
/*int count( int S[], int m, int n )
{
    int i, j, x, y;
    int table[n+1][m];
    for (i=0; i<m; i++)
        table[0][i] = 1;
    for (i = 1; i < n+1; i++)
    {
        for (j = 0; j < m; j++)
        {
            x = (i-S[j] >= 0)? table[i - S[j]][j]: 0;
            y = (j >= 1)? table[i][j-1]: 0;
            table[i][j] = x + y;
        }
    }
    return table[n][m-1];
}*/
/*int count( int S[], int m, int n )
{
    int table[n+1];
    memset(table, 0, sizeof(table));
    table[0] = 1;
    for(int i=0; i<m; i++)
        for(int j=S[i]; j<=n; j++)
            table[j] += table[j-S[i]];
    return table[n];
}*/
int main()
{
	int n,i,j,k,sum;
	scanf("%d",&n);
	int arr[] = {1234567,123456,1234};
    int m = 3;
    for(i=0;i<10;i++)
    	for(j=0;j<10;j++)
    		for(k=0;k<10;k++)
    		{
    			sum = 1234567*i + 123456*j + 1234*k;
    			if(sum == n)
    				{
    					printf("YES\n");
    					return 0;
    				}
       		}
    printf("NO\n");
    /*if(count(arr,m,n) == 0)
    	printf("NO\n");
    else
    	printf("YES\n");
    return 0;*/
    return 0;
}

#include <stdio.h>
int main()
{
	long long int n,i,j,sum,flag=0;
	scanf("%d",&n);
    for(i=0;i<1000;i++)
    	for(j=0;j<1000;j++)
    		{
    			long long int sum = n - 1234567*i - 123456*j;
    			if(sum % 1234 == 0 && sum >= 0)
    				{
    					flag = 1;
    				}
       		}

    if(flag == 0)
        printf("NO\n");
    else
        printf("YES\n");
    return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <inttypes.h>
#include <math.h>
int main()
{
	int64_t a;
	scanf("%"PRId64"", &a);
	if (a == 0)
	{
		printf("NO");
		return 0;
	}
	while (a >= 1234567)
		a = a - 1234567;
	while (a >= 123456)
		a = a - 123456;
	while (a >= 1234)
		a = a - 1234;
	printf("%"PRId64"\n", a);
	if (a == 0)
		printf("YES");
	else
		printf("NO");
	return 0;
}
/* Sat Dec 21 2019 20:41:17 GMT+0300 (MSK) */

#include<stdio.h>
#define A 1234567
#define B 123456
#define C 1234
int main()
{
          int n,count=0,i,j,k,m;
          scanf("%d",&n);
                    if(n%A==0||n%B==0||n%C==0)
                    {
                              printf("YES");
                              return 0;
                    }
                    for(i=1;i<=(n/C);i++)
                    {
                          k=C*i;
                          m=n-k;
                          if((m%A)%B==0||m%B==0)
                          {
                                printf("YES");
                                return 0;
                          }

                    }
                    printf("NO");
}

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

long long n, a, b, c, i, j, k, ver;

int main(){

	scanf("%lld" , &n);

	a = n/1234567;
	b = n/123456;
	c = n/1234;

	for(i = 0 ; i <= c ; i++){
		for(j = 0 ; j <= b ; j++){
			if((n - k*1234567 - j*123456)%1234 == 0){
				ver = 1;
				break;
			}
			if(ver == 1) break;
		}
		if(ver == 1) break;
	}

	if(ver == 1) printf("YES\n");
	else printf("NO\n");

	return 0;
}

#include<stdio.h>
#define A 1234567
#define B 123456
#define C 1234
int main()
{
          int n,count=0,i,j,k,m,t,s;
          scanf("%d",&n);
                    if(n%A==0||n%B==0||n%C==0)
                    {
                              printf("YES");
                              return 0;
                    }
                    for(i=1;i<=(n/C)+1;i++)
                    {
                          k=C*i;
                          m=n-k;
                          if((m%A)%B==0||m%B==0)
                          {
                                printf("YES");
                                return 0;
                          }
                          t=m/A;
                          s=m%A;
                          for(j=1;j<=t+1;j++)
                          {
                                if(s%B==0)
                                {
                                      printf("YES");
                                      return 0;
                                }
                                s+=A;
                          }

                    }
                    printf("NO");
}

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

int main () {
long long int n;
long long int house = 1234567;
long long int car = 123456;
long long int computer = 1234;
scanf("%lld",&n);
long long int sum = n;
if (n%house==0 || n%car==0 || n%computer==0){
	printf("YES\n");
}
else {
while(sum >= computer || sum >=car || sum >= house ) {
	if(sum>=house)
		sum-=house;
	 if(sum>=car)
		sum-=car;
	 if(sum>=computer)
		sum-=computer;
}
//printf("%lld",sum);
if (sum!=0){
	sum = n;
	while(sum>=house || sum>=car) {
		if(sum>=house)
			sum-=house;
		if(sum>=car)
			sum-=car;
	}
}
if (sum!=0){
	sum = n;
	while(sum>=house || sum>=computer) {
		if(sum>=house)
			sum-=house;
		if(sum>=computer)
			sum-=computer;
	}
}
if (sum!=0){
	sum = n;
	while(sum>=car || sum>=computer) {
		if(sum>=car)
			sum-=car;
		if(sum>=computer)
			sum-=computer;
	}
}

if(sum==0)
	printf("YES\n");
else
	printf("NO\n");
}
//printf("%d\n",pos);

return 0;
}

#include<stdio.h>
int main()
{
    long int n;
    scanf("%ld",&n);
    while(n!=0)
    {
        if(n>0)
        n=n-1234567;
        else if(n<=0)
        break;

        if(n>0)
        n=n-123456;
        else if(n<=0)
        break;

        if(n>0)
        n=n-1234;
        else if(n<=0)
        break;

    }
    if(n==0)
    printf("YES");
    else
    printf("NO");

    return 0;
}

#include <stdio.h>
const int a=1234567;
const int b=123456;
const int c=1234;
int main()
{
	int n,k;
	scanf("%i",&n);
	k=n%a;
	if(k){
		k=k%b;
		if(k)
			k=k%c;
	}
	if(k)
		puts("NO");
	else
		puts("YES");
	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <inttypes.h>
#include <math.h>
int main()
{
	int64_t a;
	scanf("%"PRId64"", &a);
	if (a == 0)
	{
		printf("NO");
		return 0;
	}
	while (a >= 1234567)
		a = a - 1234567;
	while (a >= 123456)
		a = a - 123456;
	while (a >= 1234)
		a = a - 1234;
	if (a == 0)
		printf("YES");
	else
		printf("NO");
	return 0;
}
/* Sat Dec 21 2019 20:42:56 GMT+0300 (MSK) */

#include <stdio.h>
#include <string.h>
/*int count( long long int S[], int m, long long int n )
{
    if (n == 0)
        return 1;
    if (n < 0)
        return 0;
    if (m <=0 && n >= 1)
        return 0;
    return count( S, m - 1, n ) + count( S, m, n-S[m-1] );
}*?
/*int count( int S[], int m, int n )
{
    int i, j, x, y;
    int table[n+1][m];
    for (i=0; i<m; i++)
        table[0][i] = 1;
    for (i = 1; i < n+1; i++)
    {
        for (j = 0; j < m; j++)
        {
            x = (i-S[j] >= 0)? table[i - S[j]][j]: 0;
            y = (j >= 1)? table[i][j-1]: 0;
            table[i][j] = x + y;
        }
    }
    return table[n][m-1];
}*/
/*int count( int S[], int m, int n )
{
    int table[n+1];
    memset(table, 0, sizeof(table));
    table[0] = 1;
    for(int i=0; i<m; i++)
        for(int j=S[i]; j<=n; j++)
            table[j] += table[j-S[i]];
    return table[n];
}*/
int main()
{
	int n,i,j,k,sum;
	scanf("%d",&n);
	int arr[] = {1234567,123456,1234};
    int m = 3;
    for(i=0;i<100000;i++)
    	for(j=0;j<100000;j++)
    		for(k=0;k<100000;k++)
    		{
    			sum = 1234567*i + 123456*j + 1234*k;
    			if(sum == n)
    				{
    					printf("YES\n");
    					return 0;
    				}
       		}
    printf("NO\n");
    /*if(count(arr,m,n) == 0)
    	printf("NO\n");
    else
    	printf("YES\n");
    return 0;*/
    return 0;
}

#include <stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
long long cmpfunc (const void * a, const void * b) {
   return ( *(long long*)a - *(long long*)b );
}

int main(void){

long long int test,i,j,n,count,flag=0,o1=0,o2=0,b1,x,m,l,max,sum2,min,f,c,r,o,sum1,sum=0,y,a,b,count1=0,a2,b2,k;

scanf("%lld",&n);
for(i=0;i<n/1234567+1;i++){
    for(j=0;j<n/123456+1;j++){
        if((n-a*1234567-b*123456)>=0 && (n-a*1234567-b*123456)%1234==0 ){
            printf("Yes");
            return 0;
        }
    }
}//
printf("No");
return 0;
}

#include <stdio.h>
 //Compiler version gcc 6.3.0

 int main(void)
 {
 	int n;
 	scanf("%d", &n);
 	int l1=n/1234567, l2=n/123456;
 	for(int i=0;i<=l1;i++) {
 		for(int j=0; j<l2; j++) {
 			int s=i*1234567+j*123456;
 			if(s>n) break;
 			if((n-s)%1234==0) {
 				printf("YES");
 				return 0;
 			}
 		}
 	}
 	printf("NO");
 	return 0;
 }

#include <stdio.h>
#include <string.h>
/*int count( long long int S[], int m, long long int n )
{
    if (n == 0)
        return 1;
    if (n < 0)
        return 0;
    if (m <=0 && n >= 1)
        return 0;
    return count( S, m - 1, n ) + count( S, m, n-S[m-1] );
}*?
/*int count( int S[], int m, int n )
{
    int i, j, x, y;
    int table[n+1][m];
    for (i=0; i<m; i++)
        table[0][i] = 1;
    for (i = 1; i < n+1; i++)
    {
        for (j = 0; j < m; j++)
        {
            x = (i-S[j] >= 0)? table[i - S[j]][j]: 0;
            y = (j >= 1)? table[i][j-1]: 0;
            table[i][j] = x + y;
        }
    }
    return table[n][m-1];
}*/
/*int count( int S[], int m, int n )
{
    int table[n+1];
    memset(table, 0, sizeof(table));
    table[0] = 1;
    for(int i=0; i<m; i++)
        for(int j=S[i]; j<=n; j++)
            table[j] += table[j-S[i]];
    return table[n];
}*/
int main()
{
	int n,i,j,k,sum;
	scanf("%d",&n);
	int arr[] = {1234567,123456,1234};
    int m = 3;
    for(i=0;i<10;i++)
    	for(j=0;j<10;j++)
    		for(k=0;k<10;k++)
    		{
    			sum = 1234567*i + 123456*j + 1234*k;
    			if(sum == n)
    				{
    					printf("YES\n");
    					return 0;
    				}
       		}
    /*if(count(arr,m,n) == 0)
    	printf("NO\n");
    else
    	printf("YES\n");
    return 0;*/
}

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

int main () {
long long int n;
long long int house = 1234567;
long long int car = 123456;
long long int computer = 1234;
scanf("%lld",&n);
long long int sum = n;
if (n%house==0 || n%car==0 || n%computer==0){
	printf("YES\n");
}
else {

if (sum!=0){
	sum = n;
	while(sum>=car || sum>=computer) {
		if(sum>=car)
			sum-=car;
		if(sum>=computer)
			sum-=computer;
	}
printf("%lld\n",sum);
}
 if (sum!=0){
	sum = n;
	while(sum>=house || sum>=computer) {
		if(sum>=house)
			sum-=house;
		if(sum>=computer)
			sum-=computer;
	}
printf("%lld\n",sum);
}

 if (sum!=0){
	sum = n;
	while(sum>=house || sum>=car) {
		if(sum>=house)
			sum-=house;
		if(sum>=car)
			sum-=car;
	}
printf("%lld\n",sum);
}
 if(sum!=0) {
sum = n;
while(sum >= house || sum >=car || sum >= computer ) {
	if(sum>=house)
		sum-=house;
	 if(sum>=car)
		sum-=car;
	 if(sum>=computer)
		sum-=computer;
}
printf("%lld\n",sum);
}

if(sum==0)
	printf("YES\n");
else
	printf("NO\n");
}
//printf("%d\n",pos);

return 0;
}

#include<stdio.h>
int main()
{
    int i,flag=0;
    long long n,item;
    scanf("%I64d",&n);
    item=n;
        while(item>=1234567)
        {
            item-=1234567;
        }
        while(item>=123456)
        {
            item-=123456;
        }
        while(item>=1234)
        {
            item-=1234;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }

        printf("NO\n");
    return 0;
}

#include <stdio.h>
#include <string.h>
int main()
{
	int n,i,j,sum,flag=0;
	scanf("%d",&n);
    for(i=0;i<1000;i++)
    	for(j=0;j<1000;j++)
    		{
    			int sum = n- 1234567*i + 123456*j;
    			if(sum % 1234)
    				{
    					flag = 1;
    				}
       		}

    if(flag == 0)
        printf("NO\n");
    else
        printf("YES\n");
    return 0;
}

#include<stdio.h>

#define ll long long

int main()
{
    freopen("in.txt", "r", stdin);

    ll a=1234567, b = 123456, c= 1234;

    ll n, ans, ans2, i, j;
    int flag = 0;

    scanf("%I64d", &n);

    if(n%a == 0 || n%b==0 || n%c == 0) flag = 1;

    ans = 0;

    for(i=1; flag == 0 && ans<=n ; i++) {

        ans2 = ans;

        if( ans2>0 && n%ans2 == 0) flag = 1;

        for(j=1; ans2 <= n && flag == 0 ; j++){

            if( ( n-ans2 ) % c == 0) {
                flag = 1;
                break;
            }

            ans2 = ans + j*b;
            if(n%ans2 == 0) flag = 1;
        }

        ans = i*a;
        if(n%ans==0) flag = 1;
    }

    if(flag == 1) printf("YES\n");
    else printf("NO\n");
}

#include<stdio.h>
int main()
{
    int a=1234567,b=123456,c=1234,sum,n,flag=0,i,j;
    scanf("%d",&n);
    sum=n;
    if(n%a==0 || n%b==0 || n%c==0) printf("YES\n");
    else{
    for(i=0; flag==0 ;i++)
    {
        sum=n;
        sum=sum-i*a;
        if(sum<0) break;

        for(j=0; flag==0 ; j++)
        {
            sum=sum-j*b;
            if(sum<0) break;

            if(sum%c==0) { flag=1; printf("YES\n"); }
        }
    }
    //printf("%d %d\n",i,j);
    if(flag==0) printf("NO\n");
    }

    return 0;
}

#include <stdio.h>
#include <string.h>
/*int count( long long int S[], int m, long long int n )
{
    if (n == 0)
        return 1;
    if (n < 0)
        return 0;
    if (m <=0 && n >= 1)
        return 0;
    return count( S, m - 1, n ) + count( S, m, n-S[m-1] );
}*?
/*int count( int S[], int m, int n )
{
    int i, j, x, y;
    int table[n+1][m];
    for (i=0; i<m; i++)
        table[0][i] = 1;
    for (i = 1; i < n+1; i++)
    {
        for (j = 0; j < m; j++)
        {
            x = (i-S[j] >= 0)? table[i - S[j]][j]: 0;
            y = (j >= 1)? table[i][j-1]: 0;
            table[i][j] = x + y;
        }
    }
    return table[n][m-1];
}*/
/*int count( int S[], int m, int n )
{
    int table[n+1];
    memset(table, 0, sizeof(table));
    table[0] = 1;
    for(int i=0; i<m; i++)
        for(int j=S[i]; j<=n; j++)
            table[j] += table[j-S[i]];
    return table[n];
}*/
int main()
{
	int n,i,j,k,sum;
	scanf("%d",&n);
	int arr[] = {1234567,123456,1234};
    int m = 3;
    for(i=0;i<1000000;i++)
    	for(j=0;j<1000000;j++)
    		for(k=0;k<1000000;k++)
    		{
    			sum = 1234567*i + 123456*j + 1234*k;
    			if(sum == n)
    				{
    					printf("YES\n");
    					return 0;
    				}
       		}
    printf("NO\n");
    /*if(count(arr,m,n) == 0)
    	printf("NO\n");
    else
    	printf("YES\n");
    return 0;*/
    return 0;
}

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

int main () {
long long int n;
long long int house = 1234567;
long long int car = 123456;
long long int computer = 1234;
scanf("%lld",&n);
long long int sum = n;
if (n%house==0 || n%car==0 || n%computer==0){
	printf("YES\n");
}
else {

if (sum!=0){
	sum = n;
	while(sum>=car || sum>=computer) {
		if(sum>=car)
			sum-=car;
		if(sum>=computer)
			sum-=computer;
	}
//printf("%lld\n",sum);
}
 if (sum!=0){
	sum = n;
	while(sum>=house || sum>=computer) {
		if(sum>=house)
			sum-=house;
		if(sum>=computer)
			sum-=computer;
	}
//printf("%lld\n",sum);
}

 if (sum!=0){
	sum = n;
	while(sum>=house || sum>=car) {
		if(sum>=house)
			sum-=house;
		if(sum>=car)
			sum-=car;
	}
//printf("%lld\n",sum);
}
 if(sum!=0) {
sum = n;
while(sum >= house || sum >=car || sum >= computer ) {
	if(sum>=house)
		sum-=house;
	 if(sum>=car)
		sum-=car;
	 if(sum>=computer)
		sum-=computer;
}
//printf("%lld\n",sum);
}

if(sum==0)
	printf("YES\n");
else
	printf("NO\n");
}
//printf("%d\n",pos);

return 0;
}

#include <stdio.h>

int main()
{
	long long n;
	scanf("%lld",&n);
	if(n%1359257==0) printf("YES\n");
	else printf("NO\n");

	return 0;
}

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

          int n,a=1234567,b=123456,c=1234,sum;
          scanf("%d",&n);
          sum=a+b+c;
          while(1)
          {
                    if(n>=sum)
                    {
                              n=n-sum;
                              if(n<sum&&n>=(b+c))
                              {
                                        n=n-(b+c);
                                        if(n<(b+c)&&n>=c)
                                        {
                                                  n=n-c;
                                                  if(n<c)
                                                  break;
                                        }
                              }
                    }
                    else
                    break;
          }
          if(n==0)
          printf("YES");
          else
          printf("NO");
          return 0;
}

#include <stdio.h>

int main(void) {
	// your code goes here

	int n,a,b,c,temp=1;
	scanf("%d",&n);
	for(a=0;a<=(n/1234567);a++)
	{
	    for(b=0;b<=(n/123456);b++)
	   { int k=1234567*a + 123456*b;
	   // printf("%d ",k);
	    k=n-k;
	    if(k<0){printf("NO"); temp=0; break;}
	    if(k%1234==0){printf("YES"); temp=0; break;}
	   }
	    if(temp==0)break;
	}

	if(temp!=0)printf("NO");
	return 0;
}

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

#define HOUSE    (1234567)
#define CAR      (123456)
#define COMPUTER (1234)

int main() {
  bool ok = false;
  int n,nh,ncr,i,j;

  scanf("%d", &n);
  for ( nh = n / HOUSE, i=0; i <= nh; ++i )
    for ( ncr = (n-i*HOUSE) / CAR, j=0; j <= ncr; ++j )
      if ( (n - nh*HOUSE - ncr*CAR) % COMPUTER == 0 )
        ok = true;
  printf("%s\n", ok ? "YES" : "NO");
  return EXIT_SUCCESS;
}

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

int main () {
int n;
int house = 1234567;
int car = 123456;
int computer = 1234;
scanf("%d",&n);
int sum = n;
if (n%house==0 || n%car==0 || n%computer==0){
	printf("YES\n");
}
else {
while(sum> computer || sum >car || sum > house ) {
	if(sum>=house)
		sum-=house;
	 if(sum>=car)
		sum-=car;
	 if(sum>=computer)
		sum-=computer;
}
//printf("%d",sum);
if(sum==0)
	printf("YES\n");
else
	printf("NO\n");
}
//printf("%d\n",pos);

return 0;
}

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

int main()
{

    long long unsigned int a,temp,i,j,k;
    scanf("%I64d",&a);
    temp=a;
    for(i=1;i!=1000;i++)
    {
        temp=temp-1234567;
        if(temp<=1234567)
        {
            for(j=1;j!=1000;j++)
            {
                             if(temp==0)
                {
                    printf("NO");
                    return 0;
                }
                if (temp>=123456)
                temp=temp-123456;

                if(temp<=123456)
                {
                    for(k=1;k!=1000;k++)
                    {
                                      if(temp==0)
                {
                    printf("NO");
                    return 0;
                }
                        if(temp>=1234)
                        temp=temp-1234;
                        {
                            if(temp==0)
                            {
                                printf("YES");
                                return 0;
                            }
                        }
                    }
                }

            }
            break;
        }
    }

        printf("NO");

    return 0;
}

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

//681B Economy Game.
main()
{
    int n,i,j,flag=0;
    scanf("%d",&n);
    int house=1234567,car=123456,computer=1234;

    int x=n/house,y=n/car,z=n/computer;
    int clone=n,c_copy=0;

    for(i=x; house*i>=0;i--)
    {
        clone=n-house*i;
        for(j=0;j<=y;j++)
            {
                c_copy=clone-car*j;
                if(c_copy%computer==0)
                {
                    flag=1;
                    break;
                }
            }

    }
    if(flag) printf("YES\n");
    else printf("NO\n");
    return 0;
}

#include<stdio.h>
int main()
{
    long long n,item;
    scanf("%I64d",&n);
    item=n;
        while(item>=1234567)
        {
            item-=1234567;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
        while(item>=123456)
        {
            item-=123456;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
        while(item>=1234)
        {
            item-=1234;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
    item=n;
        while(item>=123456)
        {
            item-=123456;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
        while(item>=1234)
        {
            item-=1234;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
    item=n;
        while(item>=1234)
        {
            item-=1234;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
    item=n;
        while(item>=1234567)
        {
            item-=1234567;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
        while(item>=1234)
        {
            item-=1234;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
    printf("NO\n");
    return 0;
}

#include<stdio.h>

int main()
{
    long long int a,b,c;
    a=1234567;
    b=123456;
    c=1234;
    long long int rem,n;
    scanf("%lld",&n);
    rem=n%a;
    rem=rem%b;
    rem=rem%c;

    if(rem==0){printf("YES"); }
    else printf("NO");

return 0;
}

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

int main()
{
    long long int i,a,b,j,y,x,m,cur=0,n,t,c1,c2,n1,n2,m1,m2,te,tem,temp;

    long long int sum=0,max=0,ans=0,tl=1,k,w=0,on=0,z=0,wh=0;

        scanf("%lld",&n);
       a=n/1234567;
       b=n/123456;
        for(i=0;i<=a;i++)
            for(j=0;j<=b;j++)
                {
                    te=n-(i*1234567+j*123456);
                    if(te%1234==0)
                    w=1;

                }
        if(w)
            printf("YES\n");
        else
            printf("NO\n");

    return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define max 1000000000
typedef long long ll;
int main(){
	ll n,i,j,flag,c;
	flag=-1;
	scanf("%I64d",&n);
	for(i=0;i<=100;i++){
		if((i*1234567)>n){
				continue;
			}
		for(j=0;j<=1000;j++){
			if(((i*1234567)+(j*123456))>n){
				continue;
			}
			c=n-((i*1234567)+(j*123456));
			if(c>0){
				flag=c%1234;
			}
			if(flag==0){
				break;
			}
		}
		if(flag==0){
			break;
		}
	}
	if(flag==0){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	return 0;
}

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

long long n, a, b, c, i, j, k, ver;

int main(){

	scanf("%lld" , &n);

	a = n/1234567;
	b = n/123456;

	for(i = 0 ; i <= a ; i++){
		for(j = 0 ; j <= b ; j++){
			if((n - i*1234567 - j*123456)%1234 == 0){
				ver = 1;
				break;
			}
			if(ver == 1) break;
		}
		if(ver == 1) break;
	}

	if(ver == 1) printf("YES\n");
	else printf("NO\n");

	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <inttypes.h>
#include <math.h>
int main()
{
	int64_t a;
	scanf("%"PRId64"", &a);
	while (a >= 1234567)
		a = a - 1234567;
	while (a >= 123456)
		a = a - 123456;
	while (a >= 1234)
		a = a - 1234;
	if (a == 0)
		printf("YES");
	if (a != 0)
		printf("NO");
	return 0;
}
/* Sat Dec 21 2019 20:24:26 GMT+0300 (MSK) */

#include<stdio.h>
int main()
{
    int i,flag=0;
    long long n,item;
    scanf("%I64d",&n);
    item=n;
        while(item>=1234567)
        {
            item-=1234567;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
        while(item>=123456)
        {
            item-=123456;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
        while(item>=1234)
        {
            item-=1234;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
    item=n;
        while(item>=123456)
        {
            item-=123456;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
        while(item>=1234)
        {
            item-=1234;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
    item=n;
        while(item>=1234)
        {
            item-=1234;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
    item=n;
        while(item>=1234567)
        {
            item-=1234567;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
        while(item>=1234)
        {
            item-=1234;
        }
        if(item==0)
            {
                printf("YES\n");
                return 0;
            }
        printf("NO\n");
    return 0;
}

#include <stdio.h>
#include <string.h>
int main()
{
	int n,i,j,sum,flag=0;
	scanf("%d",&n);
    for(i=0;i<1000;i++)
    	for(j=0;j<1000;j++)
    		{
    			int sum = n- 1234567*i + 123456*j;
    			if(sum % 1234 == 0)
    				{
    					flag = 1;
    				}
       		}

    if(flag == 0)
        printf("NO\n");
    else
        printf("YES\n");
    return 0;
}