#include <bits/stdc++.h>
using namespace std;
unsigned X[1024], Y[1024];
int main(void) {
  X[0] = 0;
  X[1] = 4;
  X[2] = 7;
  int s = 3;
  for (int i = 2, j = 10; i <= 9; i++, j *= 10) {
    for (int k = 0; k < 1 << (i - 1); k++) {
      X[s++] = j * 4 + X[(1 << (i - 1)) - 1 + k];
    }
    for (int k = 0; k < 1 << (i - 1); k++) {
      X[s++] = j * 7 + X[(1 << (i - 1)) - 1 + k];
    }
  }
  X[1023] = 1000000001;
  for (int i = 0; i < 1024; i++) {
    Y[i] = X[i];
  }
  unsigned ai, bi, ci, di, a, b, c, d, k;
  cin >> a >> b >> c >> d >> k;
  for (ai = 0; a > X[ai]; ai++) {
  }
  X[--ai] = a;
  for (bi = 1023; b < X[bi]; bi--) {
  }
  X[++bi] = b;
  for (ci = 0; c > Y[ci]; ci++) {
  }
  Y[--ci] = c;
  for (di = 1023; d < Y[di]; di--) {
  }
  Y[++di] = d;
  unsigned long long res = 0, all;
  for (unsigned i = ai; i < bi; i++)
    for (unsigned j = ci; j < di; j++)
      if (i - j == k || j - i == k) {
        res += (unsigned long long)(X[i + 1] - X[i] +
                                    ((i < j && i == ai || i > j && i == bi - 1)
                                         ? 1
                                         : 0)) *
               (Y[j + 1] - Y[j] +
                ((j < i && j == ci || j > i && j == di - 1) ? 1 : 0));
      }
  if (k == 1) {
    int r = min((int)bi, (int)di) - max((int)ai, (int)ci) - 1;
    if (r > 0) res -= r;
  }
  all = (unsigned long long)(b - a + 1) * (d - c + 1);
  cout.precision(15);
  cout << fixed << (double)res / all;
  return 0;
}
