#include <bits/stdc++.h>
using namespace std;
vector<int> v;
void gao(int dep, int val) {
  if (val != 0) v.push_back(val);
  if (dep == 9) return;
  gao(dep + 1, val * 10 + 4);
  gao(dep + 1, val * 10 + 7);
}
int pl, pr, vl, vr, k;
double gao() {
  double add = 0.0, ct = 0.0;
  int i;
  for (i = 0; i < v.size(); ++i) {
    int VL, VR;
    VL = v[i];
    VR = (i == v.size() - 1 ? 1000000005 : v[i + 1] - 1);
    VR = min(VR, pr);
    VL = max(VL, pl);
    if (VL > VR) continue;
    add = VR - VL + 1;
    if (i - k + 1 >= 0) {
      int nowl, nowr;
      if (i - k < 0)
        nowl = 1;
      else
        nowl = v[i - k] + 1;
      nowr = v[i - k + 1];
      int L = max(nowl, vl), R = min(nowr, vr);
      if (L <= R) {
        ct += add * (R - L + 1.0);
        if (k == 1) {
          if (v[i] >= VL && v[i] <= VR && v[i] >= L && v[i] <= R) ct -= 0.5;
        }
      }
    }
  }
  return ct;
}
int main() {
  gao(0, 0);
  sort(v.begin(), v.end());
  while (cin >> pl >> pr >> vl >> vr >> k) {
    int i;
    double ct = 0.0;
    ct += gao();
    swap(pl, vl);
    swap(pr, vr);
    ct += gao();
    printf("%.10f\n", ct / (((double)vr - vl + 1.0) * ((double)pr - pl + 1.0)));
  }
  return 0;
}
