#include <bits/stdc++.h>
using namespace std;
pair<int, int> p, v;
int k;
int range_sum(vector<pair<int, int> > rs) {
  sort(rs.begin(), rs.end());
  int S = 0, p = -99999999;
  for (int i = 0; i < (int)rs.size(); ++i) {
    S += max(0, rs[i].second - max(p, rs[i].first));
    p = max(p, rs[i].second);
  }
  return S;
}
vector<int> lucky;
void make_lucky(int n) {
  for (int i = 0; i < (1 << n); i++) {
    string t(n, '0');
    for (int j = 0; j < n; j++) {
      if ((i >> j) & 1) {
        t[n - 1 - j] = '7';
      } else {
        t[n - 1 - j] = '4';
      }
    }
    lucky.push_back(atoi(t.c_str()));
  }
}
pair<int, int> AND(pair<int, int> a, pair<int, int> b) {
  return pair<int, int>(max(a.first, b.first), min(a.second, b.second));
}
long double solve(pair<int, int> s1, pair<int, int> s2, pair<int, int> k1,
                  pair<int, int> k2, vector<pair<int, int> > &vv,
                  vector<pair<int, int> > &pp) {
  s1 = AND(s1, k1);
  if (s1.first > s1.second) return 0;
  s2 = AND(s2, k2);
  if (s2.first > s2.second) return 0;
  vv.push_back(s1);
  pp.push_back(s2);
  return (long double)(s2.second - s2.first) *
         (long double)(s1.second - s1.first);
}
int main() {
  cin >> p.first >> p.second >> v.first >> v.second >> k;
  lucky.push_back(-2);
  for (int i = 1; i <= 9; i++) make_lucky(i);
  lucky.push_back(1000001000);
  v.second++;
  p.second++;
  long double res = 0;
  vector<pair<int, int> > vv, pp;
  for (int i = 1; i < (int)lucky.size() - 1; i++) {
    int next = i + k - 1;
    if (next >= lucky.size() - 1) continue;
    pair<int, int> s1 = pair<int, int>(lucky[i - 1] + 1, lucky[i]);
    pair<int, int> s2 = pair<int, int>(lucky[next] + 1, lucky[next + 1]);
    res += solve(s1, s2, p, v, pp, vv);
    res += solve(s1, s2, v, p, vv, pp);
    pair<int, int> q1 = pair<int, int>(lucky[i], lucky[i] + 1);
    pair<int, int> q2 = pair<int, int>(lucky[next], lucky[next] + 1);
    res += solve(q1, s2, p, v, pp, vv);
    res += solve(s2, q1, p, v, pp, vv);
    res += solve(q2, s1, p, v, pp, vv);
    res += solve(s1, q2, p, v, pp, vv);
    res += solve(q1, q2, p, v, pp, vv);
    if (q1 != q2) res += solve(q1, q2, v, p, pp, vv);
  }
  cout << setprecision(32) << setiosflags(ios::fixed)
       << res / (long double)(p.second - p.first) /
              (long double)(v.second - v.first)
       << endl;
  return 0;
}
