#include <bits/stdc++.h>
using namespace std;
template <class T>
T checkmax(T &a, T b) {
  return a = max(a, b);
}
template <class T>
T checkmin(T &a, T b) {
  return a = min(a, b);
}
const double EPS = 1e-9;
const double PI = acos(-1);
const int INF = 0x3F3F3F3F;
const long long MX = 1000000000;
int lucky[1024], nl = 0;
void gen(long long seed) {
  if (seed >= MX) return;
  lucky[nl++] = seed;
  gen(seed * 10 + 4);
  gen(seed * 10 + 7);
}
int pl, pr, vl, vr;
long double lenp, lenv;
int k;
long long checkv(int id) {
  if (lucky[id] <= vl) return 0;
  int l = lucky[id - 1], r = lucky[id] - 1;
  checkmax(l, vl);
  checkmin(r, vr);
  if (l > r) return 0;
  return (r - l + 1);
}
long long check() {
  long long ans = 0;
  for (int i = 1; i < nl && lucky[i - 1] < pr; ++i) {
    if (lucky[i] < pl) continue;
    int l = lucky[i - 1] + 1, r = lucky[i];
    checkmax(l, pl);
    checkmin(r, pr);
    if (l > r) continue;
    long long p0 = (r - l + 1);
    long long pv = 0;
    if (i + k < nl && lucky[i + k - 1] <= vr) pv += checkv(i + k);
    ans += p0 * pv;
  }
  return ans;
}
double go() {
  long long ans = check();
  swap(pl, vl);
  swap(pr, vr);
  ans += check();
  if (k == 1) {
    for (int i = 1; i < nl && lucky[i] <= pr && lucky[i] <= vr; ++i) {
      if (lucky[i] >= pl && lucky[i] >= vl) --ans;
    }
  }
  return ans / lenp / lenv;
}
int main(int argc, char *argv[]) {
  gen(0);
  sort(lucky, lucky + nl);
  lucky[nl++] = MX + 1;
  while (cin >> pl >> pr >> vl >> vr >> k) {
    lenp = pr - pl + 1, lenv = vr - vl + 1;
    printf("%.10lf\n", go());
  }
}
