#include <bits/stdc++.h>
using namespace std;
int pl, pr, vl, vr, k;
int L = 1, M = 1000000000 + 1;
vector<int> v;
int unilen(int a, int b, int c, int d) {
  if (b < c or d < a) return 0;
  return min(b, d) - max(a, c) + 1;
}
int main() {
  v.push_back(0);
  cin >> pl >> pr >> vl >> vr >> k;
  for (int i = 1; i <= 9; i++) {
    int d = (1 << i);
    for (int j = 0; j < (int)(d); ++j) {
      int t = 0;
      for (int k = 0; k < (int)(i); ++k) {
        t *= 10;
        if (j & (1 << (i - 1 - k)))
          t += 7;
        else
          t += 4;
      }
      v.push_back(t);
    }
  }
  long long s = 0;
  v.push_back(M);
  for (int i = 0; i < (int)(v.size() - 1); ++i) assert(v[i] < v[i + 1]);
  for (int i = 0; i < (int)(v.size()); ++i) {
    if (i == 0) continue;
    int j = i + k;
    if (j >= (int)v.size()) break;
    s += (long long)unilen(v[i - 1] + 1, v[i], pl, pr) *
         unilen(v[j - 1], v[j] - 1, vl, vr);
    s += (long long)unilen(v[i - 1] + 1, v[i], vl, vr) *
         unilen(v[j - 1], v[j] - 1, pl, pr);
    if (k == 1 and pl <= v[i] and v[i] <= pr and vl <= v[i] and v[i] <= vr) s--;
  }
  long long P = (long long)(pr - pl + 1) * (vr - vl + 1);
  printf("%.12f", (double)s / P);
  return 0;
}
