#include <bits/stdc++.h>
using namespace std;
vector<int> lk;
void make(int num, int len) {
  if (len == 10) return;
  if (num != 0) lk.push_back(num);
  make(num * 10 + 4, len + 1);
  make(num * 10 + 7, len + 1);
}
double gao(int l1, int l2, int r1, int r2) {
  double l = max(l1, r1), r = min(l2, r2);
  return max(0.0, r - l + 1);
}
int main() {
  make(0, 0);
  sort(lk.begin(), lk.end());
  int p1, p2, v1, v2, k;
  while (cin >> p1 >> p2 >> v1 >> v2 >> k) {
    int c1 = max(p1, v1), c2 = min(c2, v2);
    double tot = (p2 - p1 + 1.0) * (v2 - v1 + 1.0), sum = 0;
    int sz = lk.size();
    for (int i = 0; i + k - 1 < sz; i++) {
      int l1, l2 = lk[i], r1 = lk[i + k - 1], r2;
      if (i == 0)
        l1 = 0;
      else
        l1 = lk[i - 1] + 1;
      if (i + k == sz)
        r2 = 1000000000;
      else
        r2 = lk[i + k] - 1;
      sum += gao(l1, l2, p1, p2) * gao(r1, r2, v1, v2);
      sum += gao(l1, l2, v1, v2) * gao(r1, r2, p1, p2);
      sum -= gao(c1, c2, max(l1, r1), min(l2, r2));
    }
    printf("%.12f\n", sum / tot);
  }
  return 0;
}
