#include <bits/stdc++.h>
using namespace std;
long long int arr[1024], i, j, k, l, pin, pfi, vin, vfi, in;
long double temp, res;
double resf;
long long int cuen(long long int ina, long long int fia, long long int inb,
                   long long int fib) {
  if ((inb >= ina) && (fib <= fia)) {
    return fib - inb + 1;
  }
  if ((ina >= inb) && (fia <= fib)) {
    return fia - ina + 1;
  }
  if ((ina <= fib) && (fib <= fia)) {
    return fib - ina + 1;
  }
  if ((ina <= inb) && (inb <= fia)) {
    return fia - inb + 1;
  }
  return 0;
}
int main() {
  arr[0] = 0;
  arr[1] = 4;
  arr[2] = 7;
  in = 1;
  k = 3;
  l = 3;
  for (i = 2; i <= 9; i++) {
    for (j = in; j < k; j++) {
      arr[l] = arr[j] * 10 + 4;
      arr[l + 1] = arr[j] * 10 + 7;
      l += 2;
    }
    in = k;
    k = l;
  }
  arr[l] = 1000000002;
  cin >> pin >> pfi >> vin >> vfi >> k;
  for (i = 1; i <= 1022 - k + 1; i++) {
    int inix = arr[i], finx = arr[i + k - 1];
    int iniy, finy;
    iniy = arr[i - 1] + 1;
    finy = arr[i + k] - 1;
    temp += (cuen(iniy, inix, vin, vfi) * cuen(finx, finy, pin, pfi));
    temp += (cuen(iniy, inix, pin, pfi) * cuen(finx, finy, vin, vfi));
    if (k == 1)
      if ((cuen(vin, vfi, arr[i], arr[i]) > 0) &&
          (cuen(pin, pfi, arr[i], arr[i]) > 0)) {
        temp--;
      }
  }
  res = ((vfi - vin + 1) * (pfi - pin + 1));
  res = temp / res;
  resf = res;
  printf("%.18f", resf);
}
