#include <bits/stdc++.h>
using namespace std;
long long labs(long long a) { return a < 0 ? (-a) : a; }
long long max(long long a, long long b) { return a > b ? a : b; }
long long min(long long a, long long b) { return a < b ? a : b; }
vector<long long> v;
long long Intersect(pair<long long, long long> p1,
                    pair<long long, long long> p2) {
  pair<long long, long long> res;
  res.first = max(p1.first, p2.first);
  res.second = min(p1.second, p2.second);
  if (res.first > res.second) return 0;
  return res.second - res.first + 1;
}
long long Len(pair<long long, long long> p) { return p.second - p.first + 1; }
int main() {
  pair<long long, long long> p1, p2;
  int k;
  cin >> p1.first >> p1.second >> p2.first >> p2.second >> k;
  for (int len = 1; len < 11; len++) {
    for (long long mask = 0; mask < (1 << len); mask++) {
      long long a = mask;
      long long num = 0;
      for (int(i) = 0; (i) < (len); (i)++) {
        num = num * 10 + (a % 2 ? 4 : 7);
        a /= 2;
      }
      v.push_back(num);
    }
  }
  v.push_back(0);
  sort((v).begin(), (v).end());
  while (v[v.size() - 2] > 1000000000) v.pop_back();
  int i1 = 1;
  int i2 = k;
  double res = 0;
  for (; i2 < v.size() - 1; i1++, i2++) {
    pair<long long, long long> g1 = make_pair(v[i1 - 1] + 1, v[i1]);
    pair<long long, long long> g2 = make_pair(v[i2], v[i2 + 1] - 1);
    res += (double)Intersect(p1, g1) / (double)Len(p1) *
           (double)Intersect(p2, g2) / (double)Len(p2);
    res += (double)Intersect(p2, g1) / (double)Len(p2) *
           (double)Intersect(p1, g2) / (double)Len(p1);
    if (k == 1) {
      pair<long long, long long> pc = make_pair(v[i1], v[i1]);
      res -= (double)Intersect(p2, pc) / (double)Len(p2) *
             (double)Intersect(p1, pc) / (double)Len(p1);
    }
  }
  printf("%.10f", res);
  return 0;
}
