#include <bits/stdc++.h>
using namespace std;
int testnum;
vector<long long> all;
void preprocess(long long num) {
  if (num <= 1000000000ll) {
    if (num > 0) all.push_back(num);
    preprocess(num * 10 + 4);
    preprocess(num * 10 + 7);
  }
}
long long al, ah, bl, bh, k;
void solve() {
  int N = all.size();
  double sum = 0;
  for (int i = 0; i + k <= N; i++) {
    long long x = all[i];
    long long y = all[i + k - 1];
    long long px, py;
    if (al <= x && bh >= y) {
      if (i == 0)
        px = al;
      else
        px = max(al, all[i - 1] + 1);
      if (i + k == N)
        py = bh;
      else
        py = min(bh, all[i + k] - 1);
      double t1 = min(x, ah) - px + 1;
      double t2 = py - max(y, bl) + 1;
      if (t1 < 0) t1 = 0;
      if (t2 < 0) t2 = 0;
      sum += t1 * t2;
    }
    if (bl <= x && ah >= y) {
      if (i == 0)
        py = bl;
      else
        py = max(bl, all[i - 1] + 1);
      if (i + k == N)
        px = ah;
      else
        px = min(ah, all[i + k] - 1);
      double t1 = px - max(y, al) + 1;
      double t2 = min(x, bh) - py + 1;
      if (t1 < 0) t1 = 0;
      if (t2 < 0) t2 = 0;
      sum += t1 * t2;
    }
    if (k == 1 && al <= x && x <= ah && bl <= x && x <= bh) sum -= 1.0;
  }
  double tot = (double)(ah - al + 1) * (double)(bh - bl + 1);
  printf("%.12lf\n", sum / tot);
}
bool input() {
  cin >> al >> ah >> bl >> bh >> k;
  return true;
}
int main() {
  preprocess(0);
  sort(all.begin(), all.end());
  int T = 1;
  for (testnum = 1; testnum <= T; testnum++) {
    if (!input()) break;
    solve();
  }
}
