#include <bits/stdc++.h>
using namespace std;
vector<int> v;
inline void dfs(int cur) {
  v.push_back(cur);
  if (10ll * cur + 4 >= 1e9) return;
  dfs(10 * cur + 4);
  dfs(10 * cur + 7);
}
int l1, r1, l2, r2, k;
inline int getlen(int l1, int r1, int l2, int r2) {
  int l = max(l1, l2), r = min(r1, r2);
  return max(r - l + 1, 0);
}
int main() {
  dfs(0);
  cin >> l1 >> r1 >> l2 >> r2 >> k;
  k--;
  sort(v.begin(), v.end());
  int s = v.size();
  v.push_back(1e9);
  long long ans = 0;
  for (int i = 1; i + k < s; i++)
    ans += 1ll * getlen(l1, r1, v[i - 1] + 1, v[i]) *
           getlen(l2, r2, v[i + k], v[i + k + 1] - 1);
  for (int i = 1; i + k < s; i++)
    ans += 1ll * getlen(l2, r2, v[i - 1] + 1, v[i]) *
           getlen(l1, r1, v[i + k], v[i + k + 1] - 1);
  if (k == 0)
    for (int i = 1; i < s; i++)
      if (getlen(l1, r1, v[i], v[i]) && getlen(l2, r2, v[i], v[i])) ans--;
  printf("%.15f", 1.0 * ans / (r1 - l1 + 1) / (r2 - l2 + 1));
}
