#include <bits/stdc++.h>
using namespace std;
int N, c;
long double l, r, a, b;
long double A[100100];
long double sol, lenl, lena;
void DFS(long long n) {
  if (n > 1e9) return;
  A[++N] = n;
  DFS(n * 10 + 4);
  DFS(n * 10 + 7);
}
long double prob(long double lol, long double hil, long double loa,
                 long double hia) {
  lol = max(lol, l);
  hil = min(hil, r);
  loa = max(loa, a);
  hia = min(hia, b);
  long double cl = (hil - lol + 1);
  long double ca = (hia - loa + 1);
  if (min(cl, ca) <= 0) return 0;
  return (cl * lenl) * (ca * lena);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << setprecision(12) << fixed;
  DFS(4);
  DFS(7);
  sort(A, A + N);
  A[0] = 0;
  A[N + 1] = 1100100100;
  cin >> l >> r >> a >> b >> c;
  lenl = (long double)(1) / (r - l + 1);
  lena = (long double)(1) / (b - a + 1);
  for (int I = c; I <= N; I++) {
    sol += prob(A[I - c] + 1, A[I - c + 1], A[I], A[I + 1] - 1);
    sol += prob(A[I], A[I + 1] - 1, A[I - c] + 1, A[I - c + 1]);
    if (c == 1) sol -= prob(A[I], A[I], A[I], A[I]);
  }
  cout << sol << endl;
}
