#include <bits/stdc++.h>
using namespace std;
vector<long long> lucky;
void cal(long long value) {
  if (value < 1000000000) lucky.push_back(value);
  if (value >= 1000000000) return;
  value *= 10;
  cal(value + 4);
  cal(value + 7);
}
int al, ar, bl, br, k;
int get_intersect(int u, int v, int l, int r) {
  u = max(u, l);
  v = min(v, r);
  return (v >= u) ? v - u + 1 : 0;
}
double solve() {
  long long Count = 0, a, b, c, d;
  for (int i = 0; i < lucky.size(); i++) {
    int j = i + k - 1;
    if (j >= lucky.size()) break;
    a = get_intersect(al, ar, lucky[i - 1] + 1, lucky[i]);
    b = get_intersect(bl, br, lucky[j], lucky[j + 1] - 1);
    Count += a * b;
    c = get_intersect(bl, br, lucky[i - 1] + 1, lucky[i]);
    d = get_intersect(al, ar, lucky[j], lucky[j + 1] - 1);
    Count += c * d;
    if (k == 1 && a && b && c && d) Count--;
  }
  a = ar - al + 1;
  b = br - bl + 1;
  return (double)Count / a / b;
}
int main() {
  lucky.push_back(-1);
  cal(4);
  cal(7);
  sort(lucky.begin(), lucky.end());
  lucky.push_back(1000000000);
  scanf("%d %d", &al, &ar);
  scanf("%d %d", &bl, &br);
  scanf("%d", &k);
  printf("%.12lf\n", solve());
  return 0;
}
