#include <bits/stdc++.h>
using namespace std;
static const int INF = 500000000;
template <class T>
void debug(T a, T b) {
  for (; a != b; ++a) cerr << *a << ' ';
  cerr << endl;
}
int luck[2005], m;
int L1, R1, L2, R2, k;
int BIL = 1000000000;
void getluck(long long int a) {
  if (a > 0 && a <= BIL) luck[m++] = a;
  if (a > BIL) return;
  getluck(a * 10 + 4);
  getluck(a * 10 + 7);
}
int main() {
  luck[m++] = -10;
  luck[m++] = BIL + 10;
  getluck(0);
  sort(luck, luck + m);
  cin >> L1 >> R1 >> L2 >> R2 >> k;
  long long int res = 0;
  for (int i = 1; i < m - k; ++i) {
    res += max(min(luck[i], R1) - max(luck[i - 1] + 1, L1) + 1, 0) *
           (long long int)max(
               0, min(luck[i + k] - 1, R2) - max(luck[i + k - 1], L2) + 1);
    res += max(min(luck[i], R2) - max(luck[i - 1] + 1, L2) + 1, 0) *
           (long long int)max(
               0, min(luck[i + k] - 1, R1) - max(luck[i + k - 1], L1) + 1);
  }
  if (k == 1) {
    for (int i = 1; i < m - 1; ++i)
      if (L1 <= luck[i] && luck[i] <= R1 && L2 <= luck[i] && luck[i] <= R2)
        --res;
  }
  double ans = res / (double)((R1 - L1 + 1) * (long long int)(R2 - L2 + 1));
  printf("%.10f\n", ans);
  return 0;
}
