#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000010;
int main() {
  vector<int> happy;
  int s0, f0, s1, f1, k;
  cin >> s0 >> f0 >> s1 >> f1 >> k;
  for (int len = 1; len < 10; len++) {
    for (int i = 0; i < (1 << len); i++) {
      int nw = 0;
      for (int j = 0; j < len; j++) {
        nw *= 10;
        if (i & (1 << j))
          nw += 4;
        else
          nw += 7;
      }
      happy.push_back(nw);
    }
  }
  sort(happy.begin(), happy.end());
  int cnt = happy.size();
  long double vars = 0.0;
  for (int i = 0; i + k <= cnt; i++) {
    int s = happy[i];
    int f = happy[i + k - 1];
    if (1) {
      int b = s0;
      if (i > 0) b = max(b, happy[i - 1] + 1);
      int count0 = min(s, f0) - b + 1;
      int c = f1;
      if (i + k < cnt) c = min(c, happy[i + k] - 1);
      int count1 = c - max(f, s1) + 1;
      if (count1 > 0 && count0 > 0)
        vars += (long double)count1 * (long double)count0;
    }
    if (1) {
      int b = s1;
      if (i > 0) b = max(b, happy[i - 1] + 1);
      int count0 = min(s, f1) - b + 1;
      int c = f0;
      if (i + k < cnt) c = min(c, happy[i + k] - 1);
      int count1 = c - max(f, s0) + 1;
      if (count1 > 0 && count0 > 0) {
        vars += (long double)count1 * (long double)count0;
        if (s == f && s >= s0 && s <= f0 && s >= s1 && s <= f1) vars -= 1.0;
      }
    }
  }
  vars /= (long double)(f1 - s1 + 1) * (long double)(f0 - s0 + 1);
  cout.precision(10);
  cout << vars;
}
