#include <bits/stdc++.h>
using namespace std;
template <typename T, typename TT>
ostream& operator<<(ostream& s, pair<T, TT> t) {
  return s << "(" << t.first << "," << t.second << ")";
}
template <typename T>
ostream& operator<<(ostream& s, vector<T> t) {
  for (int i = 0; i < t.size(); i++) s << t[i] << " ";
  return s;
}
vector<int> s;
void dfs(int first) {
  if (first >= 1000000007) return;
  s.push_back(first);
  if (first * 10LL + 4 < 1000000007) dfs(first * 10 + 4);
  if (first * 10LL + 7 < 1000000007) dfs(first * 10 + 7);
}
double g[1025], f[1025];
int K;
double solve(int a, int b, int c, int d, double n, double m) {
  if (a > b || c > d) return 0;
  int first = lower_bound(s.begin(), s.end(), b + 1) - s.begin();
  int second = lower_bound(s.begin(), s.end(), c) - s.begin() - 1;
  int len = second - first + 1;
  if (len > K) return 0;
  int k = K - len;
  for (int i = 0; i <= k; i++) g[i] = f[i] = 0;
  int pos = c, i;
  double ans = 0;
  first--, second++;
  for (i = 0; second < s.size(); second++, i++) {
    if (pos > d || i > k) break;
    g[i] = (min(s[second], d + 1) - pos + 0.) / m;
    pos = s[second];
  }
  pos = b;
  for (i = 0; first >= 0; first--, i++) {
    if (pos < a || i > k) break;
    f[i] = (pos + 0. - max(s[first], a - 1)) / n;
    pos = s[first];
  }
  for (i = 0; i <= k; i++) {
    ans += g[i] * f[k - i];
  }
  return ans;
}
double solve1(int a, int b, double n, double m) {
  if (b < a) return 0;
  int first = lower_bound(s.begin(), s.end(), a) - s.begin();
  n *= m;
  double ans = 0;
  int num = 0;
  for (; first + K < s.size(); first++) {
    int second = first + K - 1;
    if (s[second] > b) break;
    num++;
    ans += (s[first] - max(a, s[first - 1] + 1) + 1.) *
           (min(s[second + 1] - 1, b) - s[second] + 1.) / n;
  }
  ans *= 2;
  if (K == 1) ans -= num * 1. / n;
  return ans;
}
int main() {
  int i, j, T;
  s.clear();
  dfs(0);
  s.push_back(1000000000);
  sort(s.begin(), s.end());
  int a, b, c, d;
  while (~scanf("%d%d%d%d%d", &a, &b, &c, &d, &K)) {
    if (a > c) {
      swap(a, c);
      swap(b, d);
    }
    double n = b - a + 1, m = d - c + 1, ans = 0;
    if (b < c)
      ans = solve(a, b, c, d, n, m);
    else {
      if (d < b)
        ans = solve(a, c - 1, c, d, n, m) + solve(c, d, d + 1, b, m, n) +
              solve1(c, d, n, m);
      else
        ans = solve(a, c - 1, b + 1, d, n, m) + solve(a, c - 1, c, b, n, m) +
              solve(c, b, b + 1, d, n, m) + solve1(c, b, n, m);
    }
    printf("%.9lf\n", ans);
  }
}
