#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(a, b, c) for (int(a) = (b); a < (c); a++)
#define nl '\n'
#define MAXN 10000
#define fast ios_base::sync_with_stdio(0); cin.tie(0);
const ll int N = 1e9;
/*⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⣀⣀⣠⣴⣶⣶⣶⣶⣿⣿⣶⣶⣶⣤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣤⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣤⣄⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⣿⣿⣿⣿⣿⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣿⣿⣿⠟⠙⣿⣿⠈⣿⣿⣿⠟⠟⣿⣿⣿⣿⣿⣯⣇⣿⣿⣿⡏⣀⣩⡿⢿⣿⣿⣿⣿⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿⠋⣫⢁⣄⣿⣹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣄⣘⣿⣿⣿⣿⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣶⣿⣿⣿⡿⠿⠿⢿⣿⣿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡄⠘⢿⣿⣿⣿⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⣿⣿⣿⠋⠉⠀⠀⠀⠀⠀⠀⠈⠉⠉⠛⠛⠛⠛⠙⠻⠛⠉⠉⠉⠉⠙⠛⢿⣿⣿⣇⣀⣠⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⣿⣿⣿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠉⢿⣿⣿⣿⣿⣿⣿⣿⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⢸⣯⠉⢿⣿⣿⣿⣿⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠈⢿⣦⡀⠹⢿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⠀⠀⠀⠀⠀⠀⠀ ⠀⠈⢻⡄⢨⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⢃⣠⣶⣿⣿⣶⣤⣤⣄⣀⠀⠀⠀⠀⠀⣀⣤⣴⣿⣿⣿⣿⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⢤⣽⣓⠻⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⡇⣿⡿⠁⢀⣀⣈⣉⣻⣿⡿⠁⠀⠀⠀⢸⣿⣿⠟⡩⠿⣶⣤⣉⡙⠿⣿⡄⠀⠀⠀⠀⠀⢸⣿⣿⡃⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⡇⠉⠀⣴⣶⣿⣿⠻⣿⣿⣿⡆⠀⠀⠀⠘⣿⣿⣾⣷⣿⣿⣿⣿⣿⣶⣍⠁⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⡇⠀⠀⠏⠉⠉⠁⢠⣾⣿⠟⠀⠀⠀⠀⠀⠘⢿⣿⣿⣌⠭⢬⣧⡀⠉⠛⠃⠀⠀⠀⠀⠀⠈⣿⣿⣿⣿⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⣿⠃⠀⠀⠀⠐⠒⢚⡭⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠙⠛⠻⠿⠶⠾⣟⡉⠀⠀⠀⠀⠀⠀⠀⠀⠸⠟⣣⢷⣾⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⡀⠀⠀⠀⠀⠀⠉⠀⠀⢀⡆⠀⠀⠀⠀⠀⠀⠀⣼⣦⠀⠀⠀⠀⠀⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡉⠀⣿⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⣴⡟⢀⠀⢀⣀⠀⠀⠀⠀⢻⣿⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⡆⢻⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⡇⠀⠀⠀⠀⠀⢀⣼⠟⠶⠿⠆⣼⣿⡟⠰⠾⢷⡾⠿⣿⣿⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⡇⣾⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⢿⡇⠀⠀⠀⠀⢀⡾⠉⠀⣀⣀⣀⣭⣿⢿⣿⠷⣶⣷⣦⣜⣿⠿⣷⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⠟⠉⣼⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⡇⠀⠀⠀⠰⠇⣠⣶⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⢿⣿⣿⣤⠙⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⢿⣇⠀⠀⠀⢀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣾⣟⣿⣿⣿⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⢸⣷⠞⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⡀⢦⣤⣾⣿⣿⣿⣿⣿⠿⠛⠛⠛⠛⠿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣦⡶⠀⠀⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣇⠀⠙⠛⠻⣿⠟⠋⠀⠀⢀⣠⣾⣿⣿⣿⣿⠛⠛⠛⠛⠛⠛⠛⠉⠀⠀⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⣄⠀⠀⠀⠁⠀⠀⠀⠀⠘⠿⠿⠿⠿⠿⠿⠓⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⣿⡳⣄⢀⠀⠀⠀⠀⠀⠀⢀⣤⣤⣀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣿⣿⣿⣿⣯⣻⢿⣷⣦⣤⣤⣶⣿⣿⣿⣿⣿⣿⣦⠀⢀⣀⣠⠴⠄⠀⠀⠀⠀⠀⣾⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⣿⣿⣿⣿⣿⣿⣿⡳⣯⡻⠛⠛⠿⠿⠿⣿⣿⣿⣿⣿⠿⠋⠉⠀⠀⠀⠀⠀⠀⠀⣰⣿⣿⣿⣧⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡹⣦⠀⠀⠀⠀⠈⣿⣿⣿⣇⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⣿⣿⣿⣿⣿⣿⣷⣤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣀⣀⣤⣴⡾⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣮⡳⣤⡀⠀⠀⢻⣿⣿⣿⡆⠀⠀⠀⠀⠀⢀⣤⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣤⣤⣀⡀⠀⠀⠀⠀
⠀⢀⣠⣴⣶⣿⣿⣿⡿⢟⣳⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢿⣿⣿⣿⣿⣿⣦⣍⠲⢤⡀⠈⠙⢿⣇⠀⠀⠀⣀⡴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡾⣿⣿⣿⣿⣿⣷⣦⣀⠀
⢿⣿⣿⣿⡿⢟⣻⣥⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⣵⣌⠻⣿⣿⣿⣿⣿⣿⣿⣦⡙⠳⣤⣼⣧⣀⡤⢚⣵⣾⣿⣿⣿⣿⣿⢏⡛⠿⣿⣿⣿⣿⣿⣿⣷⣶⣿⣽⣿⣿⣿⣿⣿⠇
⠀⠙⠛⠻⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢏⣾⡿⢿⣷⡽⣿⣿⣿⣿⣿⣿⣿⣿⣷⢲⣤⣽⣥⣾⣿⣿⣿⣿⣿⣿⣿⡟⢸⡿⠳⣌⠛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⠀
⠀⠀⠀⠀⠙⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢿⡁⢀⣼⠀⣿⡟⢿⣿⣿⣿⣿⣿⣿⣿⡀⠈⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⣿⡀⢀⡙⢻⡄⣿⣿⣿⣿⣿⣿⣿⣿⠿⠋⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠈⠉⠛⠻⠿⢿⣿⣿⣿⣿⣿⣿⣮⢳⣾⣧⣾⣿⣿⣎⢿⣿⣿⣿⣿⣿⡿⠁⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠁⣿⣿⣾⣷⣿⠇⣿⣿⣿⣿⡿⠛⠉⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⢿⣿⣿⣿⣷⣿⣿⣿⣿⣿⣿⣦⡻⣿⣿⣿⠟⢀⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢸⣿⣿⣿⣿⣿⠀⣿⣿⡟⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣽⠟⠁⢀⣾⣿⣿⡄⢠⣿⣿⣿⣿⣿⣿⣿⠃⣼⣿⣿⣿⣿⡇⠀⣿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
*/
/*
vector<ll> getFactorization(ll x)
{
vector<ll> ret;
while (x != 1)
{
ret.push_back(spf[x]);
x = x / spf[x];
}
return ret;
}
int computeXOR(int n)
{
// If n is a multiple of 4
if (n % 4 == 0)
return n;
// If n%4 gives remainder 1
if (n % 4 == 1)
return 1;
// If n%4 gives remainder 2
if (n % 4 == 2)
return n + 1;
// If n%4 gives remainder 3
return 0;
}
ll length(ll z)
{
ll a=0;
while(z)
{
a++;
z/=10;
}
return a;
}
int prime(int z)
{
for (int i = 2; i*i<=z;i++)
{
if(z%i==0)
{
return 1;
}
}
return 0;
}
ll fastpow(ll a,ll b,ll mod)
{
if(b==0)
{
return 1;
}
ll res= fastpow(a,b/2,mod);
res=(res*res)%mod;
if(b%2==1)
{
res=(res*a)%mod;
}
return res;
}
int setBitNumber(int n)
{
if (n == 0)
return 0;
int msb = 0;
n = n / 2;
while (n != 0) {
n = n / 2;
msb++;
}
return (1 << msb);
}
if (spf[i] == i)
{
for (int j=i*i; j<N; j+=i)
if (spf[j]==j)
spf[j] = i;
}
}
}
long long nextpowerof2(ll p)
{
if(!(p&(p-1)))
{
return p;
}
return 0x8000000000000000>>(__builtin_clzll(p)-1);
}
*/
bool prime[10000001];
void Sieve(){
memset(prime, true, sizeof(prime));
for (int p=2;p*p<=10000000;p++){
if (prime[p]){
for (int i=p*p;i<=10000000;i+=p){
prime[i]=false;
}
}
}
}
bool sortbysec(const pair<ll,ll> &a,
const pair<ll,ll> &b)
{
return (a.second < b.second);
}
bool cmp(pair<int,int>&a, pair<int, int>&b)
{
if(a.first>b.first)
{
return true;
}
if(a.first==b.first && a.second< b.second)
{
return true;
}
return false;
}
vector<ll>lucky;
void check(ll l)
{
if(l>1e10)
{
return ;
}
lucky.push_back(l);
check((l*10)+4);
check((l*10)+7);
}
int main() {
check(0);
lucky.erase(lucky.begin());
fast;
ll x,y;
cin>>x>>y;
sort(lucky.begin(),lucky.end());
ll o= lower_bound(lucky.begin(),lucky.end(),x)-lucky.begin();
ll ans=0;
for(ll i=x;i<=y;i++)
{
while(i>lucky[o])
{
o++;
}
ans+=lucky[o];
}
cout<<ans<<endl;
}
1189A - Keanu Reeves | 678A - Johny Likes Numbers |
1699C - The Third Problem | 1697D - Guess The String |
754B - Ilya and tic-tac-toe game | 760A - Petr and a calendar |
1573A - Countdown | 166A - Rank List |
1631B - Fun with Even Subarrays | 727A - Transformation from A to B |
822B - Crossword solving | 1623A - Robot Cleaner |
884B - Japanese Crosswords Strike Back | 862B - Mahmoud and Ehab and the bipartiteness |
429A - Xor-tree | 1675C - Detective Task |
950A - Left-handers Right-handers and Ambidexters | 672B - Different is Good |
1C - Ancient Berland Circus | 721A - One-dimensional Japanese Crossword |
1715B - Beautiful Array | 60B - Serial Time |
453A - Little Pony and Expected Maximum | 1715A - Crossmarket |
1715C - Monoblock | 1512C - A-B Palindrome |
1679B - Stone Age Problem | 402A - Nuts |
792A - New Bus Route | 221A - Little Elephant and Function |