#include <bits/stdc++.h>
using namespace std;
vector<int> good;
long long int intersect(int a1, int b1, int a2, int b2) {
  int am = max(a1, a2), bm = min(b1, b2);
  if (am > bm) return 0;
  return bm - am + 1;
}
int main() {
  good.push_back(-1);
  for (int len = 1; len <= 9; len++) {
    for (int mask = 0; mask < (1 << len); mask++) {
      int a = 0, pow10 = 1;
      for (int i = 0; i < len; i++) {
        a += pow10 * ((mask & (1 << i)) ? 4 : 7);
        pow10 *= 10;
      }
      good.push_back(a);
    }
  }
  good.push_back(1000000001);
  sort(good.begin(), good.end());
  int a[2], b[2], k;
  scanf("%d %d %d %d %d", &a[0], &b[0], &a[1], &b[1], &k);
  long long int goodpairs = 0;
  for (int i1 = 1;; i1++) {
    int i2 = i1 + k - 1;
    if (i2 >= good.size() - 1 || good[i1] > max(b[0], b[1])) break;
    for (int ind = 0; ind <= 1; ind++) {
      long long int tmp =
          intersect(a[ind], b[ind], good[i1 - 1] + 1, good[i1]) *
          intersect(a[1 - ind], b[1 - ind], good[i2], good[i2 + 1] - 1);
      goodpairs += tmp;
    }
    if (k == 1 && good[i1] >= a[0] && good[i1] <= b[0] && good[i1] >= a[1] &&
        good[i1] <= b[1])
      goodpairs -= 1;
  }
  long long int all = 1LL * (b[0] - a[0] + 1) * 1LL * (b[1] - a[1] + 1);
  cout.precision(10);
  cout << (long double)goodpairs / (long double)all << endl;
  return 0;
}
