#include <bits/stdc++.h>   using namespace std;   vector<long long int> lucky;   long long int l, r;   void gen(long long int a) {     if (a <= 1e11) lucky.push_back(a);     if (a * 10 + 4 <= 1e11) gen(a * 10 + 4);     if (a * 10 + 7 <= 1e11) gen(a * 10 + 7);   }   void solve() {     cin >> l >> r;     gen(4);     gen(7);     sort(lucky.begin(), lucky.end());     if (l == r) {       cout << *lower_bound(lucky.begin(), lucky.end(), l);       return;     }     long long int lb = lower_bound(lucky.begin(), lucky.end(), l) - lucky.begin();     long long int ans = (min(r, lucky[lb]) - l + 1) * lucky[lb], i;     for (i = lb + 1; lucky[i] <= r; i++) {       ans += (lucky[i] - lucky[i - 1]) * lucky[i];     }     i--;     if (lucky[i] < r) {       ans += (r - lucky[i]) * lucky[i + 1];     }     cout << ans;   }   int32_t main() {     ios::sync_with_stdio(false);     long long int t = 1;     while (t--) {       solve();     }   }   