#include <bits/stdc++.h>
using namespace std;
unsigned int a[1024];
unsigned long long min(unsigned long long a, unsigned long long b) {
  if (a > b)
    return b;
  else
    return a;
}
unsigned long long length_of_cross(unsigned long long l1, unsigned long long r1,
                                   unsigned long long l2,
                                   unsigned long long r2) {
  if (r1 >= l2) {
    return min(r1, r2) - l2 + 1;
  } else
    return 0;
}
unsigned int create_new_prime(unsigned int x) {
  int p = x, q = 3, t = 3;
  while (p > 0) {
    if (p % 10 == 4) {
      x -= t;
      x += 2 * q;
      break;
    } else {
      p /= 10;
      q *= 10;
      t += q;
    }
  }
  if (p > 0)
    return x;
  else
    return (q / 3) * 4 + (x / 7) * 4;
}
int main() {
  int l1, r1, l2, r2, k;
  scanf("%d %d %d %d %d", &l1, &r1, &l2, &r2, &k);
  int p = 4, i;
  a[0] = 0;
  for (i = 1; i < 1023; i++) {
    a[i] = p;
    p = create_new_prime(p);
  }
  unsigned long long x, y, z, f, res = 0;
  a[1023] = 1000000014;
  for (i = 0; i < 1023 && i + k < 1023; i++) {
    unsigned long long left = a[i] + 1, right = a[i + 1], left2 = a[i + k],
                       right2 = a[i + k + 1] - 1;
    if (l1 < left)
      x = length_of_cross(l1, r1, left, right);
    else
      x = length_of_cross(left, right, l1, r1);
    if (l2 < left2)
      y = length_of_cross(l2, r2, left2, right2);
    else
      y = length_of_cross(left2, right2, l2, r2);
    res += (unsigned long long)x * y;
    if (l2 < left)
      z = length_of_cross(l2, r2, left, right);
    else
      z = length_of_cross(left, right, l2, r2);
    if (l1 < left2)
      f = length_of_cross(l1, r1, left2, right2);
    else
      f = length_of_cross(left2, right2, l1, r1);
    res += (unsigned long long)z * f;
    if (k == 1 && x * y && z * f) res--;
  }
  unsigned long long t = (unsigned long long)(r1 - l1 + 1) * (r2 - l2 + 1);
  double q = (double)res / t;
  cout.precision(12);
  cout << q;
  return 0;
}
