#include <bits/stdc++.h>
using namespace std;
long long lucky[1111];
int cnt, k;
void dfs(int digit, int i, int Lnumber) {
  if (i == digit) {
    ++cnt;
    lucky[cnt] = Lnumber;
    return;
  }
  dfs(digit, i + 1, Lnumber * 10 + 4);
  dfs(digit, i + 1, Lnumber * 10 + 7);
}
long long intersection(long long x1, long long y1, long long x2, long long y2) {
  long long l = max(x1, x2);
  long long r = min(y1, y2);
  if (r - l + 1 > 0)
    return r - l + 1;
  else
    return 0;
}
int main() {
  for (int digit = 1; digit <= 9; digit++) dfs(digit, 0, 0);
  lucky[0] = 0;
  ++cnt;
  lucky[cnt] = 1000000000;
  long long Pl, Pr, Vl, Vr;
  scanf("%lld%lld%lld%lld%d", &Pl, &Pr, &Vl, &Vr, &k);
  long long sum = 0;
  for (int i = 1; i <= 1022 - k + 1; i++) {
    int j = i + k - 1;
    sum += intersection(lucky[i - 1] + 1, lucky[i], Pl, Pr) *
           intersection(lucky[j], lucky[j + 1] - 1, Vl, Vr);
    if (lucky[i] > Pr) break;
  }
  for (int i = 1; i <= 1022 - k + 1; i++) {
    int j = i + k - 1;
    sum += intersection(lucky[i - 1] + 1, lucky[i], Vl, Vr) *
           intersection(lucky[j], lucky[j + 1] - 1, Pl, Pr);
    if (lucky[i] > Vr) break;
  }
  if (k == 1) {
    for (int i = 1; i <= 1022; i++) {
      sum -= (intersection(lucky[i], lucky[i], Pl, Pr) *
              intersection(lucky[i], lucky[i], Vl, Vr));
    }
  }
  cout << fixed << setprecision(10)
       << (sum * 1.0) / (Vr - Vl + 1) / (Pr - Pl + 1) << endl;
}
