#include <bits/stdc++.h>
using namespace std;
int solve(long long int s, long long int e, long long int p1,
          long long int p2) {
  if (s > e) return 0;
  if (p1 > e || p2 < s) return 0;
  return max(min(e, p2) - max(s, p1) + 1, (long long int)0);
}
int main() {
  vector<long long int> ans;
  queue<long long int> q;
  q.push(4);
  q.push(7);
  while (1) {
    long long int top = q.front();
    if (top > 10000000000) break;
    ans.push_back(top);
    q.pop();
    q.push(top * 10 + 4);
    q.push(top * 10 + 7);
  }
  sort(ans.begin(), ans.end());
  long long int p1, p2;
  long long int v1, v2;
  scanf("%lld", &p1);
  scanf("%lld", &p2);
  scanf("%lld", &v1);
  scanf("%lld", &v2);
  int k;
  scanf("%d", &k);
  long long int s = 1;
  long long int fans = 0;
  for (int i = k; i < ans.size(); i++) {
    long long int e = ans[i] - 1;
    long long int cnts1 = solve(s, ans[i - k], p1, p2);
    long long int cnts2 = solve(s, ans[i - k], v1, v2);
    long long int cnte1 = solve(ans[i - 1], e, p1, p2);
    long long int cnte2 = solve(ans[i - 1], e, v1, v2);
    long long int cnts3 = solve(max(s, ans[i - 1]), min(ans[i - k], e), p1, p2);
    long long int cnte3 = solve(max(s, ans[i - 1]), min(ans[i - k], e), v1, v2);
    fans = fans + cnts1 * cnte2 + cnts2 * cnte1 - cnte3 * cnts3;
    s = ans[i - k] + 1;
  }
  double fin = fans;
  int a = 0;
  fin = fin / ((p2 - p1 + 1) * (v2 - v1 + 1));
  printf("%0.9lf\n", fin);
}
