#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
long long p1, p2, v1, v2, l, r, x1, x2, x3, x4;
long long anss;
int k;
vector<long long> ans;
void dfs(long long x, int pos) {
  ans.push_back(x);
  if (pos >= 11) return;
  dfs(x * 10 + 4, pos + 1);
  dfs(x * 10 + 7, pos + 1);
}
long long sum(long long L, long long R, long long l, long long r) {
  if (r < L || l > R) return 0;
  long long x = max(l, L);
  long long y = min(r, R);
  return y - x + 1;
}
int main() {
  cin >> p1 >> p2 >> v1 >> v2 >> k;
  dfs(0, 1);
  sort(ans.begin(), ans.end());
  int n = ans.size();
  for (int i = 0; i + k + 1 < n; i++) {
    l = ans[i] + 1, r = ans[i + 1];
    x1 = sum(p1, p2, l, r);
    x3 = sum(v1, v2, l, r);
    l = ans[i + k], r = ans[i + k + 1] - 1;
    x2 = sum(v1, v2, l, r);
    x4 = sum(p1, p2, l, r);
    anss += x1 * x2;
    anss += x3 * x4;
    if (k == 1 && sum(p1, p2, ans[i + 1], ans[i + 1]) &&
        sum(v1, v2, ans[i + 1], ans[i + 1]))
      anss--;
  }
  printf("%.13f\n", anss * 1.0 / (p2 - p1 + 1) / (v2 - v1 + 1));
  return 0;
}
