#include <bits/stdc++.h>
int main() {
  long long int l1, r1, l2, r2, k, l, r, t;
  scanf("%lld%lld%lld%lld%lld", &l1, &r1, &l2, &r2, &k);
  if (l1 > l2)
    l = l1;
  else
    l = l2;
  if (r1 > r2)
    r = r2;
  else
    r = r1;
  if ((k >= l) && (k <= r))
    t = r - l;
  else
    t = r - l + 1;
  if (t < 0)
    t = 0;
  else
    t = t;
  printf("%lld", t);
  return 0;
}
