using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Codeforces
{
    class Program
    {
        static int ReadInt()
        {
            return Int32.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static void ReadIntArray(out int[] array, char separator = ' ')
        {
            var input = Console.ReadLine().Split(separator);
            array = new int[input.Length];
            for (int i = 0; i < input.Length; i++)
            {
                array[i] = Int32.Parse(input[i]);
            }

        }
        static int ReadNextInt(string input, int index)
        {
            var ints = input.Split(' ');
            return Int32.Parse(ints[index]);
        }
        static List<long> lucks = new List<long>();
        static void Main()
        {
            var input = Console.ReadLine();
            var l = ReadNextInt(input, 0);
            var r = ReadNextInt(input, 1);

            long res = 0;

            NextLucks(0, r);

            lucks.Sort();
            int indexLuck = 0;
            for (int i = 0; i < lucks.Count; i++)
            {
                if(lucks[i] >= l)
                {
                    indexLuck = i;
                    break;
                }
            }

            for (long i = l; i <= r; i++)
            {
                var last = Math.Min(lucks[indexLuck], r);
                res += (long)lucks[indexLuck++] * (last - i + 1);
                i = last;
            }

            Console.WriteLine(res);
        }

        private static void NextLucks(long luck, int max)
        {
            if(luck >= max)
                return;
            lucks.Add(luck * 10 + 4);
            NextLucks(luck * 10 + 4, max);
            lucks.Add(luck*10 + 7);
            NextLucks(luck*10 + 7, max);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace task121A
{
    class Program
    {
        static List<string> MyList = new List<string>();
        static List<Int64> lst = new List<Int64>();
        static void NewCh(string s)
        {
            if (s.Length == 11) return;
            MyList.Add(s);
            NewCh(s + "4");
            NewCh(s + "7");
        }

        static Int64 GetNumber(Int64 number)
        {
            Int64 result = 0;
            for (Int32 i = 0; i < MyList.Count; i++)
            {
                if (lst[i] >= number)
                {
                    result = lst[i];
                    break;
                }
            }
            return result;
        }
        static void Main(string[] args)
        {
            NewCh("4");
            NewCh("7");
            for(Int32 i = 0;i<MyList.Count;i++)
            {
                lst.Add(Int64.Parse(MyList[i]));
            }
            lst.Sort();
            /*foreach (string s in MyList)
                Console.Write(s + "  ");*/
            string[] input = Console.ReadLine().Split(' ');
            Int32 begin = Int32.Parse(input[0]);
            Int32 end = Int32.Parse(input[1]);
            Int64 ret = 0;
            for (Int64 i = begin; i <= end; )
            {
                Int64 lucky = GetNumber(i);
                Int64 n = Math.Min(lucky, end) - i + 1;
                ret += n * lucky;
                i = lucky + 1;
            }
            Console.WriteLine(ret);
            //Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Collections;

namespace Task
{
    class Program
    {
        void Solve()
        {
            // Place your code here
            xfx(0);
            luckys.Sort();

            int l = io.NextInt();
            int r = io.NextInt();

            int state = 0;
            long prevLucky = -1;
            long ans = 0;

            foreach (long lucky in luckys)
            {
                if (lucky < l)
                    continue;

                switch (state)
                {
                    case 0:
                        {
                            if (r <= lucky)
                            {
                                ans += (r - l + 1L) * lucky;
                            }
                            else
                            {
                                ans += (lucky - l + 1L) * lucky;
                            }
                            state = 1;
                        }
                        break;
                    case 1:
                        {
                            if (r <= lucky)
                            {
                                ans += ((long)r - prevLucky) * lucky;
                            }
                            else
                            {
                                ans += ((long)lucky - prevLucky) * lucky;
                            }
                        }
                        break;
                }

                if (lucky >= r)
                    break;

                prevLucky = lucky;
            }

            io.Print(ans);

        }

        MyIo io = new MyIo();

        List<long> luckys = new List<long>();

        void xfx(long current)
        {
            if (current > 0)
                luckys.Add(current);

            if (current * 10L + 4 < 10000000000L)
                xfx(current * 10 + 4);
            if (current * 10L + 7 < 10000000000L)
                xfx(current * 10 + 7);
        }

        static void Main(string[] args)
        {
            var p = new Program();

            p.Solve();
            p.io.Close();
        }
    }

    class MyIo
    {
        char[] separators = new char[] { ' ', '\t' };

#if TEST
        TextReader inputStream = new StreamReader("..\\..\\input.txt");
#else
        TextReader inputStream = System.Console.In;
#endif
        TextWriter outputStream = Console.Out;

        string[] tokens;
        int pointer;

        public string NextLine()
        {
            try
            {
                return inputStream.ReadLine();
            }
            catch (IOException)
            {
                return null;
            }
        }

        public string NextString()
        {
            try
            {
                while (tokens == null || pointer >= tokens.Length)
                {
                    tokens = NextLine().Split(separators, StringSplitOptions.RemoveEmptyEntries);
                    pointer = 0;
                }
                return tokens[pointer++];
            }
            catch (IOException)
            {
                return null;
            }
        }

        public int NextInt()
        {
            return int.Parse(NextString());
        }

        public long NextLong()
        {
            return long.Parse(NextString());
        }

        public void Print(string format, params object[] args)
        {
            outputStream.Write(format, args);
        }

        public void PrintLine(string format, params object[] args)
        {
            outputStream.WriteLine(format, args);
        }

        public void Print<T>(T o)
        {
            outputStream.Write(o);
        }

        public void PrintLine<T>(T o)
        {
            outputStream.WriteLine(o);
        }

        public void Close()
        {
            inputStream.Close();
            outputStream.Close();
        }
    }
}

#define Online

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.IO;
using System.Numerics;

namespace CF
{
    delegate double F(double x);
    delegate decimal Fdec(decimal x);

    partial class Program
    {

        static void Main(string[] args)
        {

#if FileIO
            StreamReader sr = new StreamReader("input.txt");
            StreamWriter sw = new StreamWriter("output.txt");
            Console.SetIn(sr);
            Console.SetOut(sw);
#endif

            C();

#if Online
            Console.ReadLine();
#endif

#if FileIO
            sr.Close();
            sw.Close();
#endif
        }

        static void A()
        {
            int n = ReadInt();
            for (int i = 1; i <= n; i++)
            {
                int j = i;
                bool isHappy = true;
                while (j != 0)
                {
                    if (j % 10 == 4 || j % 10 == 7)
                    {
                        j /= 10;
                    }
                    else
                    {
                        isHappy = false;
                        break;
                    }
                }
                if (isHappy)
                {
                    if (n % i == 0)
                    {
                        Console.WriteLine("YES");
                        return;
                    }
                }
            }
            Console.WriteLine("NO");
        }

        static void B()
        {
            Dictionary<string, int> hash = new Dictionary<string, int>();
            string s = ReadLine();
            for (int i = 0; i < s.Length; i++)
            {
                for (int j = i; j < s.Length; j++)
                {
                    string t = "";
                    for (int z = i; z <= j; z++)
                    {
                        t += s[z];
                    }
                    bool isHappy = true;
                    for (int z = 0; z < t.Length; z++)
                    {
                        if (!(t[z].Equals('4') || t[z].Equals('7')))
                            isHappy = false;
                    }
                    if (isHappy)
                    {
                        if (hash.ContainsKey(t))
                            hash[t]++;
                        else
                            hash.Add(t, 1);
                    }
                }
            }
            if (hash.Count == 0)
            {
                Console.WriteLine(-1);
                return;
            }
            int max = 0;
            foreach (string key in hash.Keys)
            {
                max = Math.Max(hash[key], max);
            }
            string min = "";
            foreach (string key in hash.Keys)
            {
                if (max == hash[key])
                    min = key;
            }
            foreach (string key in hash.Keys)
            {
                if (string.Compare(min, key) > 0 && hash[key] == max)
                {
                    min = key;
                }
            }
            Console.WriteLine(min);
        }

        static List<long> happy = new List<long>();
        static long[] t;

        static void dfs(int k, int p)
        {
            if (k == p)
            {
                long dec = 1;
                long res = 0;
                for (int i = p - 1; i >= 0; i--)
                {
                    res += dec * t[i];
                    dec *= 10L;
                }
                happy.Add(res);
            }
            else
            {
                t[k] = 4;
                dfs(k + 1, p);
                t[k] = 7;
                dfs(k + 1, p);
            }
        }

        static void C()
        {
            long l, r;
            ReadArray(' ');
            l = NextLong();
            r = NextLong();
            for (int i = 1; i <= 10; i++)
            {
                t = new long[i];
                dfs(0, i);
            }
            happy.Sort();
            long sum = 0;
            long left = l;
            for (int i = 0; i < happy.Count; i++)
            {
                if (happy[i] >= r)
                {
                    sum += happy[i] * (r - left + 1);
                    break;
                }
                if (happy[i] >= l)
                {
                    sum += (happy[i]) * (happy[i] - left + 1L);
                    left = happy[i] + 1;
                }
            }
            Console.WriteLine(sum);
        }

        static void D()
        {

        }

        static void E()
        {

        }

        static void TestGen()
        {

        }

    }

    public static class MyMath
    {
        public static long BinPow(long a, long n, long mod)
        {
            long res = 1;
            while (n > 0)
            {
                if ((n & 1) == 1)
                {
                    res = (res * a) % mod;
                }
                a = (a * a) % mod;
                n >>= 1;
            }
            return res;
        }

        public static long GCD(long a, long b)
        {
            while (b != 0) b = a % (a = b);
            return a;
        }

        public static int GCD(int a, int b)
        {
            while (b != 0) b = a % (a = b);
            return a;
        }

        public static long LCM(long a, long b)
        {
            return (a * b) / GCD(a, b);
        }

        public static int LCM(int a, int b)
        {
            return (a * b) / GCD(a, b);
        }
    }

    static class ArrayUtils
    {
        public static int BinarySearch(int[] a, int val)
        {
            int left = 0;
            int right = a.Length - 1;
            int mid;

            while (left < right)
            {
                mid = left + ((right - left) >> 1);
                if (val <= a[mid])
                {
                    right = mid;
                }
                else
                {
                    left = mid + 1;
                }
            }

            if (a[left] == val)
                return left;
            else
                return -1;
        }

        public static double Bisection(F f, double left, double right, double eps)
        {
            double mid;
            while (right - left > eps)
            {
                mid = left + ((right - left) / 2d);
                if (Math.Sign(f(mid)) != Math.Sign(f(left)))
                    right = mid;
                else
                    left = mid;
            }
            return (left + right) / 2d;
        }

        public static decimal TernarySearchDec(Fdec f, decimal eps, decimal l, decimal r, bool isMax)
        {
            decimal m1, m2;
            while (r - l > eps)
            {
                m1 = l + (r - l) / 3m;
                m2 = r - (r - l) / 3m;
                if (f(m1) < f(m2))
                    if (isMax)
                        l = m1;
                    else
                        r = m2;
                else
                    if (isMax)
                        r = m2;
                    else
                        l = m1;
            }
            return r;
        }

        public static double TernarySearch(F f, double eps, double l, double r, bool isMax)
        {
            double m1, m2;
            while (r - l > eps)
            {
                m1 = l + (r - l) / 3d;
                m2 = r - (r - l) / 3d;
                if (f(m1) < f(m2))
                    if (isMax)
                        l = m1;
                    else
                        r = m2;
                else
                    if (isMax)
                        r = m2;
                    else
                        l = m1;
            }
            return r;
        }

        public static void Merge<T>(T[] A, int p, int q, int r, T[] L, T[] R, Comparison<T> comp)
        {
            for (int i = p; i <= q; i++)
                L[i] = A[i];
            for (int i = q + 1; i <= r; i++)
                R[i] = A[i];

            for (int k = p, i = p, j = q + 1; k <= r; k++)
            {
                if (i > q)
                {
                    for (; k <= r; k++, j++)
                        A[k] = R[j];
                    return;
                }
                if (j > r)
                {
                    for (; k <= r; k++, i++)
                        A[k] = L[i];
                    return;
                }
                if (comp(L[i], R[j]) <= 0)
                {
                    A[k] = L[i];
                    i++;
                }
                else
                {
                    A[k] = R[j];
                    j++;
                }
            }
        }

        public static void Merge_Sort<T>(T[] A, int p, int r, T[] L, T[] R, Comparison<T> comp)
        {
            if (p >= r) return;
            int q = p + ((r - p) >> 1);
            Merge_Sort(A, p, q, L, R, comp);
            Merge_Sort(A, q + 1, r, L, R, comp);
            Merge(A, p, q, r, L, R, comp);
        }

        public static void Merge<T>(T[] A, int p, int q, int r, T[] L, T[] R) where T : IComparable<T>
        {
            for (int i = p; i <= q; i++)
                L[i] = A[i];
            for (int i = q + 1; i <= r; i++)
                R[i] = A[i];

            for (int k = p, i = p, j = q + 1; k <= r; k++)
            {
                if (i > q)
                {
                    for (; k <= r; k++, j++)
                        A[k] = R[j];
                    return;
                }
                if (j > r)
                {
                    for (; k <= r; k++, i++)
                        A[k] = L[i];
                    return;
                }
                if (L[i].CompareTo(R[j]) >= 0)
                {
                    A[k] = L[i];
                    i++;
                }
                else
                {
                    A[k] = R[j];
                    j++;
                }
            }
        }

        public static void Merge_Sort<T>(T[] A, int p, int r, T[] L, T[] R) where T : IComparable<T>
        {
            if (p >= r) return;
            int q = p + ((r - p) >> 1);
            Merge_Sort(A, p, q, L, R);
            Merge_Sort(A, q + 1, r, L, R);
            Merge(A, p, q, r, L, R);
        }

        public static void Merge_Sort1<T>(T[] A, int p, int r, T[] L, T[] R) where T : IComparable<T>
        {
            int k = 1;
            while (k < r - p + 1)
            {
                int i = 0;
                while (i < r)
                {
                    int _r = Math.Min(i + 2 * k - 1, r);
                    int q = Math.Min(i + k - 1, r);
                    Merge(A, i, q, _r, L, R);
                    i += 2 * k;
                }
                k <<= 1;
            }
        }

        public static void Merge_Sort1<T>(T[] A, int p, int r, T[] L, T[] R, Comparison<T> comp)
        {
            int k = 1;
            while (k < r - p + 1)
            {
                int i = 0;
                while (i < r)
                {
                    int _r = Math.Min(i + 2 * k - 1, r);
                    int q = Math.Min(i + k - 1, r);
                    Merge(A, i, q, _r, L, R, comp);
                    i += 2 * k;
                }
                k <<= 1;
            }
        }

        static void Shake<T>(T[] a)
        {
            Random rnd = new Random(Environment.TickCount);
            T temp;
            int b, c;
            for (int i = 0; i < a.Length; i++)
            {
                b = rnd.Next(0, a.Length);
                c = rnd.Next(0, a.Length);
                temp = a[b];
                a[b] = a[c];
                a[c] = temp;
            }
        }
    }

    partial class Program
    {
        static string[] tokens;
        static int cur_token = 0;

        static void ReadArray(char sep)
        {
            cur_token = 0;
            tokens = Console.ReadLine().Split(sep);
        }

        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        static int NextInt()
        {
            return int.Parse(tokens[cur_token++]);
        }

        static long NextLong()
        {
            return long.Parse(tokens[cur_token++]);
        }

        static double NextDouble()
        {
            return double.Parse(tokens[cur_token++]);
        }

        static decimal NextDecimal()
        {
            return decimal.Parse(tokens[cur_token++]);
        }

        static string NextToken()
        {
            return tokens[cur_token++];
        }

        static string ReadLine()
        {
            return Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace _27_10_11_3_
{
    class Program
    {
        static void Main()
        {
            int k=1, j, d;
            Int64[] m = new Int64[1024];
            m[0]=0;
            m[1]=4;
            m[2]=7;
            while (k < 9)
            {
                j=2;
                d=1;
                for (int i = 0; i < k; i++)
                {
                    j *=  2;
                    d*=10;
                }
                j-=2;
                for (int i = j; i < j + (j + 2) / 2; i++)
                    m[i+1] = m[i+1 - (j + 2) / 2]+d*4;
                for (int i = j+(j+2)/2; i < j + (j + 2); i++)
                    m[i+1] = m[i+1 - (j + 2)]+d*7;
                k += 1;
            }
            m[1023] = 4444444444;

            //for(int i=0; i<m.Length; i++)
            //    Console.Write("{0} ",m[i]);
            string s1=Console.ReadLine();
            string[] s2=Regex.Split(s1, " ");
            int mi = Int32.Parse(s2[0]);
            int ma = Int32.Parse(s2[1]);
            Int64 s=0;

            for (int i = 0; i < 1023; i++)
            {
                if (mi > m[i] && ma <= m[i + 1])
                    s += m[i + 1] * (ma - mi + 1);
                if (mi > m[i] && mi<=m[i+1] && ma > m[i + 1])
                    s += m[i + 1] * (m[i + 1] - mi + 1);
                if (mi <= m[i] && ma>m[i] && ma <= m[i + 1])
                    s += m[i + 1] * (ma - m[i]);
                if (mi <= m[i] && ma > m[i + 1])
                    s += m[i + 1] * (m[i + 1] - m[i]);
            }
            Console.WriteLine("{0}", s);

            //Console.ReadLine();
        }
        /*static int[] Second(int[] i, int j)
        {
            int l;
            if (j >= 0)
            {
                for(i=0; i<)
            }
        }*/
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace Lucky_Sum
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            var lucky = new List<long> {4, 7};

            int l = Next();
            int r = Next();

            int first = 0;
            int last = 1;
            long d = 10;
            do
            {
                for (int i = first; i <= last; i++)
                {
                    lucky.Add(d*4 + lucky[i]);
                    lucky.Add(d*7 + lucky[i]);
                }
                d *= 10;
                first = last + 1;
                last = lucky.Count - 1;
            } while (lucky[last] < r);

            long sum = 0;

            lucky.Sort();

            int il = lucky.BinarySearch(l);
            if (il < 0)
                il = ~il;

            int ir = lucky.BinarySearch(r);
            if (ir < 0)
                ir = ~ir;

            if (il == ir)
            {
                sum = lucky[ir]*(r - l + 1);
            }
            else
            {
                sum = lucky[il]*(lucky[il] - l + 1);
                sum += lucky[ir]*(r - lucky[ir - 1]);

                for (int i = il + 1; i < ir; i++)
                {
                    sum += lucky[i]*(lucky[i] - lucky[i - 1]);
                }
            }

            writer.WriteLine(sum);
            writer.Flush();
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;

namespace _LuckySum
{
    class ProgramLuckySum
    {
        static List<ulong> GetLuckyNumbers(int length)
        {
            var strNums = new List<string> {"4", "7"};
            while (strNums[strNums.Count - 1].Length < length)
            {
                var count = strNums.Count;
                for (var i=0; i<count; i++)
                {
                    strNums.Add(strNums[i] + "4");
                    strNums.Add(strNums[i] + "7");
                }
            }

            return strNums.Select(ulong.Parse).ToList();
        }

        static void Main(string[] args)
        {
            var luckyNumbers = GetLuckyNumbers(11);
            luckyNumbers.Sort();

            var input = Console.ReadLine();
            if (string.IsNullOrEmpty(input)) return;
            var lr = input.Split(' ');
            var l = ulong.Parse(lr[0]);
            var r = ulong.Parse(lr[1]);

            var i = 0;
            while (luckyNumbers[i] < l)
            {
                i++;
            }
            var sum = 0UL;

            var current = l;
            while (luckyNumbers[i] <= r)
            {
                sum += luckyNumbers[i]*(luckyNumbers[i] - current + 1);
                current = luckyNumbers[i++] + 1;
            }
            sum += luckyNumbers[i] * (r - current + 1);

            Console.WriteLine(sum);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeForces
{
   class B
   {
      static void Main(string[] args)
      {
         string[] token =  Console.ReadLine().Split();
         int l = int.Parse(token[0]);
         int r = int.Parse(token[1]);

         List<long> li = new List<long> ();
		   li.Add (4);
	      li.Add (7);
	      int last = 0;
		   int num = 2;
		   bool stop = false;
	   	while (true) {
   			for (int i = last; i < num; i++) {
   				string temp = "4" + li [i];
   				if (temp.Length >= 12) {
   					stop = true;
   					break;
   				}
   				li.Add (long.Parse (temp));
   			}
   			for (int i = last; i < num; i++) {
   				string temp = "7" + li [i];
   				if (temp.Length >= 12) {
   					stop = true;
   					break;
   				}
   				li.Add (long.Parse (temp));
   			}
   			last = num;
   			num *= 2;
   			if (stop) {
   				break;
   			}
	   	}
		li.Sort ();
       long ans = 0;
      int cnt = 0;
     for (int i = 0; i < li.Count; i++)
      {
          if(li[i] >= l)
          {
              cnt = i;
              break;
          }
      }

      for (long i = l; i <= r; i++)
      {
          var last2 = Math.Min(li[cnt], r);
          ans += (long)li[cnt++] * (last2 - i + 1);
          i = last2;
      }

     Console.WriteLine(ans);

      }
  }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Numerics;

class Program
{
    static TextReader reader;
    static TextWriter writer;
    static Program()
    {
#if ONLINE_JUDGE
        reader = Console.In;
        writer = Console.Out;
#else
        reader = new StreamReader("input.txt");
        writer = new StreamWriter("output.txt");
#endif
    }
    static long gcd(long a, long b)
    {
        if (a < b)
        {
            long t = a;
            a = b;
            b = t;
        }
        return (b > 0) ? gcd(b, a % b) : a;
    }
    static void _235A()
    {
        long n = long.Parse(reader.ReadLine()), ans = n * (n - 1);
        if (n < 3)
            ans = n;
        else if (n % 2 == 1)
            ans *= n - 2;
        else
        {
            long t = (n - 2) / 2;
            for (long i = n - 3; i > (n - 2) / 2; --i)
            {
                long g = gcd(n, i);
                if (g == 1)
                    t = Math.Max(t, i);
            }
            ans *= t;
        }
        writer.Write(Math.Max(ans, (n - 1) * (n - 2) * (n - 3)));
    }
    static void _106C()
    {
        string[] s = reader.ReadLine().Split();
        int n = int.Parse(s[0]), m = int.Parse(s[1]), c0 = int.Parse(s[2]), d0 = int.Parse(s[3]);
        int[] a = new int[m + 1], b = new int[m + 1], c = new int[m + 1], d = new int[m + 1];
        for (int i = 1; i <= m; ++i)
        {
            s = reader.ReadLine().Split();
            a[i] = int.Parse(s[0]);
            b[i] = int.Parse(s[1]);
            c[i] = int.Parse(s[2]);
            d[i] = int.Parse(s[3]);
        }
        int[,] dp = new int[m + 1, n + 1];
        for (int i = 1; i * c0 <= n; ++i)
            dp[0, i * c0] = i * d0;
        for (int i = 1; i <= m; ++i)
        {
            for (int j = 1; j <= n; ++j)
            {
                if (j < c[i])
                    dp[i, j] = dp[i - 1, j];
                else
                {
                    for (int k = 0; k * b[i] <= a[i]; ++k)
                    {
                        int t = c[i] * k;
                        if (t <= j)
                            dp[i, j] = Math.Max(d[i] * k + dp[i - 1, j - t], dp[i, j]);
                    }
                }
                dp[i, j] = Math.Max(dp[i, j - 1], dp[i, j]);
            }
        }
        writer.Write(dp[m, n]);
    }
    static long pow(long a, long x, long mod)
    {
        long res = 1;
        while (x > 0)
        {
            if ((x & 1) != 0)
            {
                res = (res * a) % mod;
                --x;
            }
            else
            {
                a = (a * a) % mod;
                x >>= 1;
            }
        }
        return res;
    }
    static void _300C()
    {
        string[] s = reader.ReadLine().Split();
        long a = long.Parse(s[0]), b = long.Parse(s[1]), n = long.Parse(s[2]);
        if (a > b)
        {
            long t = a;
            a = b;
            b = t;
        }
        long[] fact = new long[n + 1];
        fact[0] = fact[1] = 1;
        long mod = 1000000007;
        for (long i = 2; i <= n; ++i)
            fact[i] = fact[i - 1] * i % mod;
        long an = n, bn = 0;
        long ans = 0;
        while (an >= 0)
        {
            long num = an * a + bn * b;
            bool ok = true;
            for (long p = 10; ok && p <= 10000000; p *= 10)
            {
                long t = num % p / (p / 10);
                if (t != a && t != b && (t != 0 || p <= num))
                    ok = false;
            }
            if (ok)
            {
                long c = (((fact[n] * pow(fact[an], mod - 2, mod)) % mod) * pow(fact[bn], mod - 2, mod)) % mod;
                ans += c;
                ans %= mod;
            }
            --an;
            ++bn;
        }
        writer.Write(ans);
    }
    static void _250B()
    {
        string s = reader.ReadLine();
        int n = int.Parse(s);
        for (int i = 0; i < n; ++i)
        {
            s = reader.ReadLine();
            string[] ip = new string[8];
            int nums = 0;
            for (int l = 0, j = 0; j < s.Length; ++j)
            {
                if (s[j] == ':')
                {
                    if (nums > 0)
                    {
                        //ip[l] = "";
                        for (int k = j - nums; k < j; ++k)
                            ip[l] += s[k];
                        ++l;
                        nums = 0;
                    }
                    else
                        break;
                }
                else
                    ++nums;
            }
            nums = 0;
            //if (ip[7] == null)
            {
                for (int r = 7, j = s.Length - 1; j >= 0; --j)
                {
                    if (ip[r] != null)
                        break;
                    if (s[j] == ':')
                    {
                        if (nums > 0)
                        {
                            for (int k = j + 1; k <= j + nums; ++k)
                                ip[r] += s[k];
                            --r;
                            nums = 0;
                        }
                        else
                            break;
                    }
                    else
                        ++nums;
                }
            }
            for (int j = 0; j < 8; ++j)
            {
                if (ip[j] == null)
                    ip[j] = "";
                while (ip[j].Length < 4)
                    ip[j] = '0' + ip[j];
            }
            for (int j = 0; j < 7; ++j)
                writer.Write(ip[j]+':');
            writer.WriteLine(ip[7]);
        }
    }
    static void _316B2()
    {
        string[] s = reader.ReadLine().Split();
        int n = int.Parse(s[0]), x = int.Parse(s[1]);
        s = reader.ReadLine().Split();
        Dictionary<int, int> queue = new Dictionary<int, int>();
        LinkedList<int> undef = new LinkedList<int>();
        for (int i = 1; i <= n; ++i)
        {
            int h = int.Parse(s[i - 1]);
            if (h > 0)
                queue.Add(h, i);
            else
                undef.AddLast(i);
        }
        int[] lens = new int[undef.Count];
        int c = 0, index = 0;
        foreach (int v in undef)
        {
            int next = v;
            lens[c] = 1;
            while (true)
            {
                if (next == x)
                {
                    index = lens[c];
                    lens[c] = 0;
                    break;
                }
                if (queue.ContainsKey(next))
                {
                    next = queue[next];
                    ++lens[c];
                }
                else
                    break;
            }
            ++c;
        }
        bool[,] dp = new bool[2, n + 1];
        dp[0,0] = true;
        for (int i = 0; i < lens.Length; ++i)
        {
            if (lens[i] > 0)
            {
                dp[1,lens[i]] = true;
                for (int j = 1; j + lens[i] <= n; ++j)
                {
                    if (dp[0,j])
                    {
                        dp[1, j + lens[i]] = true;
                    }
                }
                for (int j = 1; j <= n; ++j)
                {
                    dp[0, j] = dp[0, j] || dp[1, j];
                    dp[1, j] = false;
                }
            }
        }
        for (int i = 0; i <= n; ++i)
            if (dp[0,i])
                writer.WriteLine(i + index);
    }
    static void _121A()
    {
        string[] lr = reader.ReadLine().Split();
        long l = long.Parse(lr[0]), r = long.Parse(lr[1]);
        SortedSet<long> set = new SortedSet<long>();
        set.Add(4);
        set.Add(7);
        for (long p = 10; p <= 1000000000; p *= 10)
        {
            SortedSet<long> s = new SortedSet<long>(set);
            foreach (long e in s)
            {
                if (e / (p / 10) > 0)
                {
                    set.Add(e + p * 4);
                    set.Add(e + p * 7);
                }
            }
        }
        while (set.ElementAt(0) < l)
            set.Remove(set.ElementAt(0));
        long max = set.Max;
        while (set.Max > r)
        {
            max = set.Max;
            set.Remove(set.Max);
        }
        if (set.Max < r)
            set.Add(max);
        else
            max = set.Max;
        long[] happy = new long[set.Count];
        long c = 0;
        foreach (long e in set)
            happy[c++] = e;
        long min = set.Min;
        long sum = 0;
        if (happy.Length == 1)
            sum = (r - l + 1) * happy[0];
        else
            sum = min * (min - l + 1);// +max * (max - r + 1);
        for (long i = 1; i < happy.Length; ++i)
            sum += (Math.Min(r,happy[i]) - happy[i - 1]) * happy[i];
        writer.Write(sum);
    }
    static void Main(string[] args)
    {
        //_235A();
        //_106C();
        //_300C();
        //_250B();
        //_316B2();
        _121A();
        reader.Close();
        writer.Close();
    }
}

//

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Threading;
using System.Diagnostics;
using System.Globalization;
using System.Text.RegularExpressions;
using System.Linq;

namespace sar_cs
{
    static class Helpers
    {
        public static string AsString(this double a, int digits)
        {
            return a.ToString("F" + digits, CultureInfo.InvariantCulture);
        }

        public static Stopwatch SW = Stopwatch.StartNew();
    }

    public class Program
    {
        #region Helpers
        public class Parser
        {
            const int BufSize = 2457600;
            TextReader s;
            char[] buf = new char[BufSize];
            int bufPos;
            int bufDataSize;
            bool eos;   // eos read to buffer
            int lastChar = -2;
            int nextChar = -2;
            StringBuilder sb = new StringBuilder();

            void FillBuf()
            {
                if (eos) return;
                bufDataSize = s.Read(buf, 0, BufSize);
                if (bufDataSize == 0) eos = true;
                bufPos = 0;
            }

            int Read()
            {
                if (nextChar != -2)
                {
                    lastChar = nextChar;
                    nextChar = -2;
                }
                else
                {
                    if (bufPos == bufDataSize) FillBuf();
                    if (eos) lastChar = -1;
                    else lastChar = buf[bufPos++];
                }
                return lastChar;
            }

            void Back()
            {
                if (lastChar == -2) throw new Exception();  // no chars were ever read
                nextChar = lastChar;
            }

            public Parser()
            {
                s = Console.In;
            }

            public int ReadInt()
            {
                int res = 0;
                int sign = -1;
                int c;
                do { c = Read(); } while (c >= 0 && char.IsWhiteSpace((char)c));
                if (c == '-')
                {
                    sign = 1;
                    c = Read();
                }
                int len = 0;
                while (c >= 0 && !char.IsWhiteSpace((char)c))
                {
                    if ((uint)(c -= 48) >= 10) throw new InvalidDataException();
                    len++;
                    res = checked(res * 10 - c);
                    c = Read();
                }
                if (len == 0) throw new InvalidDataException();
                Back();
                return checked(res * sign);
            }

            public long ReadLong()
            {
                long res = 0;
                int sign = -1;
                int c;
                do { c = Read(); } while (c >= 0 && char.IsWhiteSpace((char)c));
                if (c == '-')
                {
                    sign = 1;
                    c = Read();
                }
                int len = 0;

                while (c >= 0 && !char.IsWhiteSpace((char)c))
                {
                    if ((uint)(c -= 48) >= 10) throw new InvalidDataException();
                    len++;
                    res = checked(res * 10 - c);
                    c = Read();
                }
                if (len == 0) throw new InvalidDataException();
                Back();
                return checked(res * sign);
            }

            public int ReadLnInt()
            {
                int res = ReadInt(); ReadLine(); return res;
            }

            public long ReadLnLong()
            {
                long res = ReadLong(); ReadLine(); return res;
            }

            public double ReadDouble()
            {
                int c;
                do { c = Read(); } while (c >= 0 && char.IsWhiteSpace((char)c));

                int sign = 1;
                if (c == '-')
                {
                    sign = -1;
                    c = Read();
                }

                sb.Length = 0;
                while (c >= 0 && !char.IsWhiteSpace((char)c))
                {
                    sb.Append((char)c);
                    c = Read();
                }

                Back();
                var res = double.Parse(sb.ToString(), CultureInfo.InvariantCulture);
                return res * sign;
            }

            public string ReadLine()
            {
                int c = Read();
                sb.Length = 0;
                while (c != -1 && c != 13 && c != 10)
                {
                    sb.Append((char)c);
                    c = Read();
                }
                if (c == 13)
                {
                    c = Read();
                    if (c != 10) Back();
                }
                return sb.ToString();
            }

            public bool EOF
            {
                get
                {
                    if (Read() == -1) return true;
                    Back();
                    return false;
                }
            }

            public bool SeekEOF
            {
                get
                {
                L0:
                    int c = Read();
                    if (c == -1) return true;
                    if (char.IsWhiteSpace((char)c)) goto L0;
                    Back();
                    return false;
                }
            }

            public int[] ReadIntArr(int n)
            {
                var a = new int[n]; for (int i = 0; i < n; i++) a[i] = ReadInt(); return a;
            }

            public long[] ReadLongArr(int n)
            {
                var a = new long[n]; for (int i = 0; i < n; i++) a[i] = ReadLong(); return a;
            }
        }

        static void pe() { Console.WriteLine("???"); Environment.Exit(0); }

        static void re() { Environment.Exit(55); }

        static int nosol()
        {
            Console.WriteLine("ERROR");
            return 0;
        }

        static void Swap<T>(ref T a, ref T b)
        {
            T t = a;
            a = b;
            b = t;
        }

        /// <summary>Mono lacks this override of string.Join()</summary>
        static string Join<T>(IEnumerable<T> objs)
        {
            var sb = new StringBuilder();
            foreach (var s in objs)
            {
                if (sb.Length != 0) sb.Append(' ');
                sb.Append(s);
            }
            return sb.ToString();
        }

        #endregion Helpers

        static StringBuilder sb = new StringBuilder();
        static Random rand = new Random(52345235);

        static int next_digit(int d)
        {
            switch (d)
            {
                case 0:
                case 1:
                case 2:
                case 3:
                case 4: return 4;
                case 5:
                case 6:
                case 7: return 7;
                case 8:
                case 9: return 14;
                default: throw new Exception();
            }
        }

        static long[] fours = { 0, 4, 44, 444, 4444, 44444, 444444, 4444444, 44444444, 444444444, 4444444444 };

        static long next(long n)
        {
            long m = 1;

            for (int i = 0; m <= n; i++)
            {
            L0:
                int d = (int)(n / m) % 10;
                if (d != 4 && d != 7)
                {
                    n += m;
                    n = n / m * m + fours[i];
                    goto L0;
                }
                m *= 10;
            }
            return n;
        }

        static long sum(long a, long b)
        {
            checked
            {
                return (a + b) * (b - a + 1) / 2;
            }
        }

        static long sol2(long l, long r)
        {
            long sum = 0;
            for (long i = l; i <= r; i++)
            {
                long t = next(i);
                sum += t;
            }
            return sum;
        }

        static long sol1(long l, long r)
        {
            long res = 0;
            long lastAdded = l - 1;

            while (l <= r)
            {
                long t = next(l);
                if (t > r) t = r;

                checked
                {
                    res += next(lastAdded + 1) * (t - lastAdded); lastAdded = t;
                }
                l = t + 1;
            }

            return res;
        }

        static int Main(string[] args)
        {
            //for (long i = 8; i <= 100; i++) Console.WriteLine(next(i));
            //return 0;

            //Console.SetIn(File.OpenText("_input"));
            //test(); return 0;
            var parser = new Parser();
            while (!parser.SeekEOF)
            {
                long l = parser.ReadInt(), r = parser.ReadInt();

                long res1 = sol1(l, r);

                //for (l = 1; l <= 1000; l++)
                //    for (r = l; r <= 1000; r++)
                //    {
                //        long res1 = sol1(l, r);
                //        long res2 = sol2(l, r);
                //        if (res1 != res2) throw new Exception();
                //    }

                Console.WriteLine(res1);
            }

            return 0;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgrammingContest.Codeforces.Round91 {
    class A {
        static List<long> num = new List<long>();
        static void gen(long x) {
            if (x <= 10000000000L) {
                num.Add(x);
                gen(x * 10 + 4);
                gen(x * 10 + 7);
            }
        }

        //
        static void Main() {
            var xs = Array.ConvertAll<string, int>(Console.ReadLine().Split(' '), int.Parse);
            int a = xs[0],
                b = xs[1];
            gen(0);
            num.Sort();
            long res = 0;
            for (int i = 0; ; i++) {
                if (num[i+1] < a) {
                    continue;
                }
                if (num[i+1] > b) {
                    res += (b - Math.Max(num[i], a-1)) * num[i + 1];
                    break;
                }
                res += (num[i + 1] - Math.Max(num[i], a-1)) * num[i + 1];
            }
            Console.WriteLine(res);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Andy
{
    static List<long> ans = new List<long>();
    public static void Main()
    {
        Gen(0);
        ans.Sort();
        var ii = Console.ReadLine().Split(' ');
        var l = int.Parse(ii[0]);
        var r = int.Parse(ii[1]);
        long res = 0;
        for(int i=0;i+1<ans.Count;i++)
        {
            long cl = ans[i] + 1;
            long cr = ans[i + 1];
            cl = Math.Max(cl, l);
            cr = Math.Min(cr, r);
            if (cl <= cr)
                res += (cr - cl + 1) * ans[i + 1];
        }
        //res = res != 0 ? res : ans[ans.Count - 2];
        Console.Write(res);
    }

    public static void Gen(long cur)
    {
        if (cur > 10000000000)
            return;
        ans.Add(cur);
        Gen(10 * cur + 4);
        Gen(10 * cur + 7);
    }

}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Andy
{
    static List<long> ans = new List<long>();
    public static void Main()
    {
        Gen(0);
        ans.Sort();
        var ii = Console.ReadLine().Split(' ');
        var l = int.Parse(ii[0]);
        var r = int.Parse(ii[1]);
        long res = 0;
        for(int i=0;i+1<ans.Count;i++)
        {
            long cl = ans[i] + 1;
            long cr = ans[i + 1];
            cl = Math.Max(cl, l);
            cr = Math.Min(cr, r);
            if (cl <= cr)
                res += (cr - cl + 1) * ans[i + 1];
        }
        Console.Write(res);
    }

    public static void Gen(long cur)
    {
        if (cur > 1000000000)
            return;
        ans.Add(cur);
        Gen(10 * cur + 4);
        Gen(10 * cur + 7);
    }

}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace task121A
{
    class Program
    {
        static List<string> MyList = new List<string>();
        static List<Int64> lst = new List<Int64>();
        static void NewCh(string s)
        {
            if (s.Length == 10) return;
            MyList.Add(s);
            NewCh(s + "4");
            NewCh(s + "7");
        }

        static Int64 GetNumber(Int32 number)
        {
            Int64 result = 0;
            for (Int32 i = 0; i < MyList.Count; i++)
            {
                if (lst[i] >= number)
                {
                    result = lst[i];
                    break;
                }
            }
            return result;
        }
        static void Main(string[] args)
        {
            NewCh("4");
            NewCh("7");
            for(Int32 i = 0;i<MyList.Count;i++)
            {
                lst.Add(Int64.Parse(MyList[i]));
            }
            lst.Sort();
            /*foreach (string s in MyList)
                Console.Write(s + "  ");*/
            string[] input = Console.ReadLine().Split(' ');
            Int32 begin = Int32.Parse(input[0]);
            Int32 end = Int32.Parse(input[1]);
            Int64 result = 0;
            for (Int32 i = begin; i <= end; i++)
            {
                result += GetNumber(i);
            }
            Console.WriteLine(result);
            //Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Collections;

namespace Task
{
    class Program
    {
        void Solve()
        {
            // Place your code here
            xfx(0);
            luckys.Sort();

            int l = io.NextInt();
            int r = io.NextInt();

            int state = 0;
            int prevLucky = -1;
            long ans = 0;

            foreach (int lucky in luckys)
            {
                if (lucky < l)
                    continue;

                switch (state)
                {
                    case 0:
                        {
                            if (r <= lucky)
                            {
                                ans += (r - l + 1L) * lucky;
                            }
                            else
                            {
                                ans += (lucky - l + 1L) * lucky;
                            }
                            state = 1;
                        }
                        break;
                    case 1:
                        {
                            if (r <= lucky)
                            {
                                ans += ((long)r - prevLucky) * lucky;
                            }
                            else
                            {
                                ans += ((long)lucky - prevLucky) * lucky;
                            }
                        }
                        break;
                }

                if (lucky >= r)
                    break;

                prevLucky = lucky;
            }

            io.Print(ans);

        }

        MyIo io = new MyIo();

        List<int> luckys = new List<int>();

        void xfx(int current)
        {
            if (current > 0)
                luckys.Add(current);

            if (current * 10L + 4 < int.MaxValue)
                xfx(current * 10 + 4);
            if (current * 10L + 7 < int.MaxValue)
                xfx(current * 10 + 7);
        }

        static void Main(string[] args)
        {
            var p = new Program();

            p.Solve();
            p.io.Close();
        }
    }

    class MyIo
    {
        char[] separators = new char[] { ' ', '\t' };

#if TEST
        TextReader inputStream = new StreamReader("..\\..\\input.txt");
#else
        TextReader inputStream = System.Console.In;
#endif
        TextWriter outputStream = Console.Out;

        string[] tokens;
        int pointer;

        public string NextLine()
        {
            try
            {
                return inputStream.ReadLine();
            }
            catch (IOException)
            {
                return null;
            }
        }

        public string NextString()
        {
            try
            {
                while (tokens == null || pointer >= tokens.Length)
                {
                    tokens = NextLine().Split(separators, StringSplitOptions.RemoveEmptyEntries);
                    pointer = 0;
                }
                return tokens[pointer++];
            }
            catch (IOException)
            {
                return null;
            }
        }

        public int NextInt()
        {
            return int.Parse(NextString());
        }

        public long NextLong()
        {
            return long.Parse(NextString());
        }

        public void Print(string format, params object[] args)
        {
            outputStream.Write(format, args);
        }

        public void PrintLine(string format, params object[] args)
        {
            outputStream.WriteLine(format, args);
        }

        public void Print<T>(T o)
        {
            outputStream.Write(o);
        }

        public void PrintLine<T>(T o)
        {
            outputStream.WriteLine(o);
        }

        public void Close()
        {
            inputStream.Close();
            outputStream.Close();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Codeforces
{
    class Program
    {
        static int ReadInt()
        {
            return Int32.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static void ReadIntArray(out int[] array, char separator = ' ')
        {
            var input = Console.ReadLine().Split(separator);
            array = new int[input.Length];
            for (int i = 0; i < input.Length; i++)
            {
                array[i] = Int32.Parse(input[i]);
            }

        }
        static int ReadNextInt(string input, int index)
        {
            var ints = input.Split(' ');
            return Int32.Parse(ints[index]);
        }
        static List<int> lucks = new List<int>(){4,7};
        static void Main()
        {
            var input = Console.ReadLine();
            var l = ReadNextInt(input, 0);
            var r = ReadNextInt(input, 1);

            long res = 0;
            while (true)
            {
                NextLucks();
                if(lucks.Count > 0 && lucks.Last() >= r)
                    break;
            }
            lucks.Sort();
            int indexLuck = 0;
            for (int i = 0; i < lucks.Count; i++)
            {
                if(lucks[i] >= l)
                {
                    indexLuck = i;
                    break;
                }
            }

            for (int i = l; i <= r; i++)
            {
                var last = Math.Min(lucks[indexLuck], r);
                res += (long)lucks[indexLuck++] * (last - i + 1);
                i = last;
            }

            Console.WriteLine(res);
        }

        private static void NextLucks()
        {
            var l1 = lucks[lucks.Count - 2];
            var l2 = lucks[lucks.Count - 1];
            var n = l1*10 + 4;
            lucks.Add(n);
            n = l1*10 + 7;
            lucks.Add(n);
            n = l2*10 + 4;
            lucks.Add(n);
            n = l2*10 + 7;
            lucks.Add(n);

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Codeforces
{
    class Program
    {
        static int ReadInt()
        {
            return Int32.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static void ReadIntArray(out int[] array, char separator = ' ')
        {
            var input = Console.ReadLine().Split(separator);
            array = new int[input.Length];
            for (int i = 0; i < input.Length; i++)
            {
                array[i] = Int32.Parse(input[i]);
            }

        }
        static int ReadNextInt(string input, int index)
        {
            var ints = input.Split(' ');
            return Int32.Parse(ints[index]);
        }
        static void Main()
        {
            var input = Console.ReadLine();
            var l = ReadNextInt(input, 0);
            var r = ReadNextInt(input, 1);

            int luck4 = 0;
            int luck7 = 0;
            long res = 0;
            var lucks = new List<int>();
            while (true)
            {
                luck4 = NextLuck(luck4, 4);
                luck7 = NextLuck(luck7, 7);
                if(luck4 >= l)
                    lucks.Add(luck4);
                if(luck7 >= l)
                    lucks.Add(luck7);

                if(luck4 > r && luck7 > r)
                    break;
            }
            lucks.Sort();
            int indexLuck = 0;
            for (int i = l; i <= r; i++)
            {
                res += (long)lucks[indexLuck] * (lucks[indexLuck] - i + 1);
                i = lucks[indexLuck++];
            }

            Console.WriteLine(res);
        }

        private static int NextLuck(int luck, int n)
        {
            return luck*10 + n;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Codeforces
{
    class Program
    {
        static int ReadInt()
        {
            return Int32.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static void ReadIntArray(out int[] array, char separator = ' ')
        {
            var input = Console.ReadLine().Split(separator);
            array = new int[input.Length];
            for (int i = 0; i < input.Length; i++)
            {
                array[i] = Int32.Parse(input[i]);
            }

        }
        static int ReadNextInt(string input, int index)
        {
            var ints = input.Split(' ');
            return Int32.Parse(ints[index]);
        }
        static void Main()
        {
            var input = Console.ReadLine();
            var l = ReadNextInt(input, 0);
            var r = ReadNextInt(input, 1);

            int luck4 = 0;
            int luck7 = 0;
            long res = 0;
            var lucks = new List<int>();
            while (true)
            {
                luck4 = NextLuck(luck4, 4);
                luck7 = NextLuck(luck7, 7);
                if(luck4 >= l)
                    lucks.Add(luck4);
                if(luck7 >= l)
                    lucks.Add(luck7);

                if(luck4 > r && luck7 > r)
                    break;
            }
            lucks.Sort();
            int indexLuck = 0;
            for (int i = l; i <= r; i++)
            {
                var last = Math.Min(lucks[indexLuck], r);
                res += (long)lucks[indexLuck++] * (last - i + 1);
                i = last;
            }

            Console.WriteLine(res);
        }

        private static int NextLuck(int luck, int n)
        {
            return luck*10 + n;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeForces
{
   class C
   {
      static void Main(string[] args)
      {
         string[] token =  Console.ReadLine().Split();
         int l = int.Parse(token[0]);
         int r = int.Parse(token[1]);

         List<long> li = new List<long> ();
		   li.Add (4);
	      li.Add (7);
	      int last = 0;
		   int num = 2;
		   bool stop = false;
	   	while (true) {
   			for (int i = last; i < num; i++) {
   				string temp = "4" + li [i];
   				if (temp.Length >= 11) {
   					stop = true;
   					break;
   				}
   				li.Add (long.Parse (temp));
   			}
   			for (int i = last; i < num; i++) {
   				string temp = "7" + li [i];
   				if (temp.Length >= 11) {
   					stop = true;
   					break;
   				}
   				li.Add (long.Parse (temp));
   			}
   			last = num;
   			num *= 2;
   			if (stop) {
   				break;
   			}
	   	}
		li.Sort ();
      long ans = 0;
      int cnt = 0;
     for (int i = 0; i < li.Count; i++)
      {
          if(li[i] >= l)
          {
              cnt = i;
              break;
          }
      }

      for (long i = l; i <= r; i++)
      {
          var last2 = Math.Min(li[cnt], r);
          ans += (long)li[cnt++] * (last2 - i + 1);
          i = last2;
      }

     Console.WriteLine(ans);

      }
  }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeForces
{
   class B
   {
      static void Main(string[] args)
      {
         string[] token =  Console.ReadLine().Split();
         int l = int.Parse(token[0]);
         int r = int.Parse(token[1]);

         List<int> li = new List<int> ();
		   li.Add (4);
	      li.Add (7);
	      int last = 0;
		   int num = 2;
		   bool stop = false;
	   	while (true) {
   			for (int i = last; i < num; i++) {
   				string temp = "4" + li [i];
   					if (temp.Length >= 10) {
   					stop = true;
   					break;
   				}
   				li.Add (int.Parse (temp));
   			}
   			for (int i = last; i < num; i++) {
   				string temp = "7" + li [i];
   				if (temp.Length >= 10) {
   					stop = true;
   					break;
   				}
   				li.Add (int.Parse (temp));
   			}
   			last = num;
   			num *= 2;
   			if (stop) {
   				break;
   			}
	   	}
		li.Sort ();
      int ans = 0;
      int cnt = 1;
      for(int i=0;i<=l;i++){
         if(li[cnt]==i)
          cnt++;
      }
      for(int i=l;i<=r;i++)
      {
         ans += li[cnt-1];
         if(i==li[cnt-1])cnt++;
      }
       Console.WriteLine(ans);

      }
  }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Numerics;

class Program
{
    static TextReader reader;
    static TextWriter writer;
    static Program()
    {
#if ONLINE_JUDGE
        reader = Console.In;
        writer = Console.Out;
#else
        reader = new StreamReader("input.txt");
        writer = new StreamWriter("output.txt");
#endif
    }
    static long gcd(long a, long b)
    {
        if (a < b)
        {
            long t = a;
            a = b;
            b = t;
        }
        return (b > 0) ? gcd(b, a % b) : a;
    }
    static void _235A()
    {
        long n = long.Parse(reader.ReadLine()), ans = n * (n - 1);
        if (n < 3)
            ans = n;
        else if (n % 2 == 1)
            ans *= n - 2;
        else
        {
            long t = (n - 2) / 2;
            for (long i = n - 3; i > (n - 2) / 2; --i)
            {
                long g = gcd(n, i);
                if (g == 1)
                    t = Math.Max(t, i);
            }
            ans *= t;
        }
        writer.Write(Math.Max(ans, (n - 1) * (n - 2) * (n - 3)));
    }
    static void _106C()
    {
        string[] s = reader.ReadLine().Split();
        int n = int.Parse(s[0]), m = int.Parse(s[1]), c0 = int.Parse(s[2]), d0 = int.Parse(s[3]);
        int[] a = new int[m + 1], b = new int[m + 1], c = new int[m + 1], d = new int[m + 1];
        for (int i = 1; i <= m; ++i)
        {
            s = reader.ReadLine().Split();
            a[i] = int.Parse(s[0]);
            b[i] = int.Parse(s[1]);
            c[i] = int.Parse(s[2]);
            d[i] = int.Parse(s[3]);
        }
        int[,] dp = new int[m + 1, n + 1];
        for (int i = 1; i * c0 <= n; ++i)
            dp[0, i * c0] = i * d0;
        for (int i = 1; i <= m; ++i)
        {
            for (int j = 1; j <= n; ++j)
            {
                if (j < c[i])
                    dp[i, j] = dp[i - 1, j];
                else
                {
                    for (int k = 0; k * b[i] <= a[i]; ++k)
                    {
                        int t = c[i] * k;
                        if (t <= j)
                            dp[i, j] = Math.Max(d[i] * k + dp[i - 1, j - t], dp[i, j]);
                    }
                }
                dp[i, j] = Math.Max(dp[i, j - 1], dp[i, j]);
            }
        }
        writer.Write(dp[m, n]);
    }
    static long pow(long a, long x, long mod)
    {
        long res = 1;
        while (x > 0)
        {
            if ((x & 1) != 0)
            {
                res = (res * a) % mod;
                --x;
            }
            else
            {
                a = (a * a) % mod;
                x >>= 1;
            }
        }
        return res;
    }
    static void _300C()
    {
        string[] s = reader.ReadLine().Split();
        long a = long.Parse(s[0]), b = long.Parse(s[1]), n = long.Parse(s[2]);
        if (a > b)
        {
            long t = a;
            a = b;
            b = t;
        }
        long[] fact = new long[n + 1];
        fact[0] = fact[1] = 1;
        long mod = 1000000007;
        for (long i = 2; i <= n; ++i)
            fact[i] = fact[i - 1] * i % mod;
        long an = n, bn = 0;
        long ans = 0;
        while (an >= 0)
        {
            long num = an * a + bn * b;
            bool ok = true;
            for (long p = 10; ok && p <= 10000000; p *= 10)
            {
                long t = num % p / (p / 10);
                if (t != a && t != b && (t != 0 || p <= num))
                    ok = false;
            }
            if (ok)
            {
                long c = (((fact[n] * pow(fact[an], mod - 2, mod)) % mod) * pow(fact[bn], mod - 2, mod)) % mod;
                ans += c;
                ans %= mod;
            }
            --an;
            ++bn;
        }
        writer.Write(ans);
    }
    static void _250B()
    {
        string s = reader.ReadLine();
        int n = int.Parse(s);
        for (int i = 0; i < n; ++i)
        {
            s = reader.ReadLine();
            string[] ip = new string[8];
            int nums = 0;
            for (int l = 0, j = 0; j < s.Length; ++j)
            {
                if (s[j] == ':')
                {
                    if (nums > 0)
                    {
                        //ip[l] = "";
                        for (int k = j - nums; k < j; ++k)
                            ip[l] += s[k];
                        ++l;
                        nums = 0;
                    }
                    else
                        break;
                }
                else
                    ++nums;
            }
            nums = 0;
            //if (ip[7] == null)
            {
                for (int r = 7, j = s.Length - 1; j >= 0; --j)
                {
                    if (ip[r] != null)
                        break;
                    if (s[j] == ':')
                    {
                        if (nums > 0)
                        {
                            for (int k = j + 1; k <= j + nums; ++k)
                                ip[r] += s[k];
                            --r;
                            nums = 0;
                        }
                        else
                            break;
                    }
                    else
                        ++nums;
                }
            }
            for (int j = 0; j < 8; ++j)
            {
                if (ip[j] == null)
                    ip[j] = "";
                while (ip[j].Length < 4)
                    ip[j] = '0' + ip[j];
            }
            for (int j = 0; j < 7; ++j)
                writer.Write(ip[j]+':');
            writer.WriteLine(ip[7]);
        }
    }
    static void _316B2()
    {
        string[] s = reader.ReadLine().Split();
        int n = int.Parse(s[0]), x = int.Parse(s[1]);
        s = reader.ReadLine().Split();
        Dictionary<int, int> queue = new Dictionary<int, int>();
        LinkedList<int> undef = new LinkedList<int>();
        for (int i = 1; i <= n; ++i)
        {
            int h = int.Parse(s[i - 1]);
            if (h > 0)
                queue.Add(h, i);
            else
                undef.AddLast(i);
        }
        int[] lens = new int[undef.Count];
        int c = 0, index = 0;
        foreach (int v in undef)
        {
            int next = v;
            lens[c] = 1;
            while (true)
            {
                if (next == x)
                {
                    index = lens[c];
                    lens[c] = 0;
                    break;
                }
                if (queue.ContainsKey(next))
                {
                    next = queue[next];
                    ++lens[c];
                }
                else
                    break;
            }
            ++c;
        }
        bool[,] dp = new bool[2, n + 1];
        dp[0,0] = true;
        for (int i = 0; i < lens.Length; ++i)
        {
            if (lens[i] > 0)
            {
                dp[1,lens[i]] = true;
                for (int j = 1; j + lens[i] <= n; ++j)
                {
                    if (dp[0,j])
                    {
                        dp[1, j + lens[i]] = true;
                    }
                }
                for (int j = 1; j <= n; ++j)
                {
                    dp[0, j] = dp[0, j] || dp[1, j];
                    dp[1, j] = false;
                }
            }
        }
        for (int i = 0; i <= n; ++i)
            if (dp[0,i])
                writer.WriteLine(i + index);
    }
    static void _121A()
    {
        string[] lr = reader.ReadLine().Split();
        int l = int.Parse(lr[0]), r = int.Parse(lr[1]);
        SortedSet<int> set = new SortedSet<int>();
        set.Add(4);
        set.Add(7);
        for (int p = 10; p < 1000000000; p *= 10)
        {
            SortedSet<int> s = new SortedSet<int>(set);
            foreach (int e in s)
            {
                if (e / (p / 10) > 0)
                {
                    set.Add(e + p * 4);
                    set.Add(e + p * 7);
                }
            }
        }
        while (set.ElementAt(0) < l)
            set.Remove(set.ElementAt(0));
        int max = set.Max;
        while (set.Max > r)
        {
            max = set.Max;
            set.Remove(set.Max);
        }
        if (set.Max < r)
            set.Add(max);
        int[] happy = new int[set.Count];
        int c = 0;
        foreach (int e in set)
            happy[c++] = e;
        int min = set.Min;
        long sum = 0;
        if (happy.Length == 1)
            sum = (r - l + 1) * happy[0];
        else
        {
            sum = min * (min - l + 1) + max * (r - max + 1);
        }
        for (int i = 1; i < happy.Length; ++i)
            sum += (happy[i] - happy[i - 1] - 1) * happy[i];
        writer.Write(sum);
    }
    static void Main(string[] args)
    {
        //_235A();
        //_106C();
        //_300C();
        //_250B();
        //_316B2();
        _121A();
        reader.Close();
        writer.Close();
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Numerics;

class Program
{
    static TextReader reader;
    static TextWriter writer;
    static Program()
    {
#if ONLINE_JUDGE
        reader = Console.In;
        writer = Console.Out;
#else
        reader = new StreamReader("input.txt");
        writer = new StreamWriter("output.txt");
#endif
    }
    static long gcd(long a, long b)
    {
        if (a < b)
        {
            long t = a;
            a = b;
            b = t;
        }
        return (b > 0) ? gcd(b, a % b) : a;
    }
    static void _235A()
    {
        long n = long.Parse(reader.ReadLine()), ans = n * (n - 1);
        if (n < 3)
            ans = n;
        else if (n % 2 == 1)
            ans *= n - 2;
        else
        {
            long t = (n - 2) / 2;
            for (long i = n - 3; i > (n - 2) / 2; --i)
            {
                long g = gcd(n, i);
                if (g == 1)
                    t = Math.Max(t, i);
            }
            ans *= t;
        }
        writer.Write(Math.Max(ans, (n - 1) * (n - 2) * (n - 3)));
    }
    static void _106C()
    {
        string[] s = reader.ReadLine().Split();
        int n = int.Parse(s[0]), m = int.Parse(s[1]), c0 = int.Parse(s[2]), d0 = int.Parse(s[3]);
        int[] a = new int[m + 1], b = new int[m + 1], c = new int[m + 1], d = new int[m + 1];
        for (int i = 1; i <= m; ++i)
        {
            s = reader.ReadLine().Split();
            a[i] = int.Parse(s[0]);
            b[i] = int.Parse(s[1]);
            c[i] = int.Parse(s[2]);
            d[i] = int.Parse(s[3]);
        }
        int[,] dp = new int[m + 1, n + 1];
        for (int i = 1; i * c0 <= n; ++i)
            dp[0, i * c0] = i * d0;
        for (int i = 1; i <= m; ++i)
        {
            for (int j = 1; j <= n; ++j)
            {
                if (j < c[i])
                    dp[i, j] = dp[i - 1, j];
                else
                {
                    for (int k = 0; k * b[i] <= a[i]; ++k)
                    {
                        int t = c[i] * k;
                        if (t <= j)
                            dp[i, j] = Math.Max(d[i] * k + dp[i - 1, j - t], dp[i, j]);
                    }
                }
                dp[i, j] = Math.Max(dp[i, j - 1], dp[i, j]);
            }
        }
        writer.Write(dp[m, n]);
    }
    static long pow(long a, long x, long mod)
    {
        long res = 1;
        while (x > 0)
        {
            if ((x & 1) != 0)
            {
                res = (res * a) % mod;
                --x;
            }
            else
            {
                a = (a * a) % mod;
                x >>= 1;
            }
        }
        return res;
    }
    static void _300C()
    {
        string[] s = reader.ReadLine().Split();
        long a = long.Parse(s[0]), b = long.Parse(s[1]), n = long.Parse(s[2]);
        if (a > b)
        {
            long t = a;
            a = b;
            b = t;
        }
        long[] fact = new long[n + 1];
        fact[0] = fact[1] = 1;
        long mod = 1000000007;
        for (long i = 2; i <= n; ++i)
            fact[i] = fact[i - 1] * i % mod;
        long an = n, bn = 0;
        long ans = 0;
        while (an >= 0)
        {
            long num = an * a + bn * b;
            bool ok = true;
            for (long p = 10; ok && p <= 10000000; p *= 10)
            {
                long t = num % p / (p / 10);
                if (t != a && t != b && (t != 0 || p <= num))
                    ok = false;
            }
            if (ok)
            {
                long c = (((fact[n] * pow(fact[an], mod - 2, mod)) % mod) * pow(fact[bn], mod - 2, mod)) % mod;
                ans += c;
                ans %= mod;
            }
            --an;
            ++bn;
        }
        writer.Write(ans);
    }
    static void _250B()
    {
        string s = reader.ReadLine();
        int n = int.Parse(s);
        for (int i = 0; i < n; ++i)
        {
            s = reader.ReadLine();
            string[] ip = new string[8];
            int nums = 0;
            for (int l = 0, j = 0; j < s.Length; ++j)
            {
                if (s[j] == ':')
                {
                    if (nums > 0)
                    {
                        //ip[l] = "";
                        for (int k = j - nums; k < j; ++k)
                            ip[l] += s[k];
                        ++l;
                        nums = 0;
                    }
                    else
                        break;
                }
                else
                    ++nums;
            }
            nums = 0;
            //if (ip[7] == null)
            {
                for (int r = 7, j = s.Length - 1; j >= 0; --j)
                {
                    if (ip[r] != null)
                        break;
                    if (s[j] == ':')
                    {
                        if (nums > 0)
                        {
                            for (int k = j + 1; k <= j + nums; ++k)
                                ip[r] += s[k];
                            --r;
                            nums = 0;
                        }
                        else
                            break;
                    }
                    else
                        ++nums;
                }
            }
            for (int j = 0; j < 8; ++j)
            {
                if (ip[j] == null)
                    ip[j] = "";
                while (ip[j].Length < 4)
                    ip[j] = '0' + ip[j];
            }
            for (int j = 0; j < 7; ++j)
                writer.Write(ip[j]+':');
            writer.WriteLine(ip[7]);
        }
    }
    static void _316B2()
    {
        string[] s = reader.ReadLine().Split();
        int n = int.Parse(s[0]), x = int.Parse(s[1]);
        s = reader.ReadLine().Split();
        Dictionary<int, int> queue = new Dictionary<int, int>();
        LinkedList<int> undef = new LinkedList<int>();
        for (int i = 1; i <= n; ++i)
        {
            int h = int.Parse(s[i - 1]);
            if (h > 0)
                queue.Add(h, i);
            else
                undef.AddLast(i);
        }
        int[] lens = new int[undef.Count];
        int c = 0, index = 0;
        foreach (int v in undef)
        {
            int next = v;
            lens[c] = 1;
            while (true)
            {
                if (next == x)
                {
                    index = lens[c];
                    lens[c] = 0;
                    break;
                }
                if (queue.ContainsKey(next))
                {
                    next = queue[next];
                    ++lens[c];
                }
                else
                    break;
            }
            ++c;
        }
        bool[,] dp = new bool[2, n + 1];
        dp[0,0] = true;
        for (int i = 0; i < lens.Length; ++i)
        {
            if (lens[i] > 0)
            {
                dp[1,lens[i]] = true;
                for (int j = 1; j + lens[i] <= n; ++j)
                {
                    if (dp[0,j])
                    {
                        dp[1, j + lens[i]] = true;
                    }
                }
                for (int j = 1; j <= n; ++j)
                {
                    dp[0, j] = dp[0, j] || dp[1, j];
                    dp[1, j] = false;
                }
            }
        }
        for (int i = 0; i <= n; ++i)
            if (dp[0,i])
                writer.WriteLine(i + index);
    }
    static void _121A()
    {
        string[] lr = reader.ReadLine().Split();
        int l = int.Parse(lr[0]), r = int.Parse(lr[1]);
        SortedSet<int> set = new SortedSet<int>();
        set.Add(4);
        set.Add(7);
        for (int p = 10; p < 1000000000; p *= 10)
        {
            SortedSet<int> s = new SortedSet<int>(set);
            foreach (int e in s)
            {
                if (e / (p / 10) > 0)
                {
                    set.Add(e + p * 4);
                    set.Add(e + p * 7);
                }
            }
        }
        while (set.ElementAt(0) < l)
            set.Remove(set.ElementAt(0));
        int max = set.Max;
        while (set.Max > r)
        {
            max = set.Max;
            set.Remove(set.Max);
        }
        if (set.Max < r)
            set.Add(max);
        else
            max = set.Max;
        int[] happy = new int[set.Count];
        int c = 0;
        foreach (int e in set)
            happy[c++] = e;
        int min = set.Min;
        long sum = 0;
        if (happy.Length == 1)
            sum = (r - l + 1) * happy[0];
        else
        {
            sum = min * (min - l + 1) + max * (r - max + 1);
        }
        for (int i = 1; i < happy.Length; ++i)
            sum += (happy[i] - happy[i - 1] - 1) * happy[i];
        writer.Write(sum);
    }
    static void Main(string[] args)
    {
        //_235A();
        //_106C();
        //_300C();
        //_250B();
        //_316B2();
        _121A();
        reader.Close();
        writer.Close();
    }
}