#include <bits/stdc++.h>
using namespace std;
long long l1, l2, r1, r2;
vector<long long> v;
void f(long long x) {
  if (x > r1 && x > r2) return;
  if (x >= min(l1, l2) && x <= max(r1, r2)) v.push_back(x);
  f(x * 10 + 7);
  f(x * 10 + 4);
}
int main() {
  long long n, k, i, mn, mx;
  double db = 0;
  cin >> l1 >> r1 >> l2 >> r2 >> k;
  f(0);
  sort(v.begin(), v.end());
  long long l = 0, r = k - 1;
  double ans = 0;
  for (r = k - 1; r < v.size(); r++) {
    long long x = min(v[l], r1);
    long long y = max(v[r], l2);
    long long mn, mx, q1 = 0, q2 = 0;
    if (l == 0)
      mn = l1;
    else
      mn = max(l1, v[l - 1] + 1);
    if (r == v.size() - 1)
      mx = r2;
    else
      mx = min(v[r + 1] - 1, r2);
    if ((mx - y + 1) > 0 && (x - mn + 1) > 0)
      ans += (1.0 * ((x - mn + 1) * (mx - y + 1))) /
             (1.0 * (r1 - l1 + 1) * (r2 - l2 + 1)),
          q1 = 1;
    x = max(v[r], l1);
    y = min(v[l], r2);
    if (l == 0)
      mn = l2;
    else
      mn = max(l2, v[l - 1] + 1);
    if (r == v.size() - 1)
      mx = r1;
    else
      mx = min(v[r + 1] - 1, r1);
    if ((y - mn + 1) > 0 && (mx - x + 1) > 0)
      ans += (1.0 * (y - mn + 1) * (mx - x + 1)) /
             (1.0 * (r1 - l1 + 1) * (r2 - l2 + 1)),
          q2 = 1;
    if (q1 == 1 && q2 == 1 && k == 1)
      ans -= (1.0 / (1.0 * (r1 - l1 + 1) * (r2 - l2 + 1)));
    l++;
  }
  printf("%.15f", min(1.0, ans));
}
