#include <bits/stdc++.h>
int main() {
  long long int l[3], r[3], k, min, max;
  scanf("%lld%lld", &l[1], &r[1]);
  scanf("%lld%lld", &l[2], &r[2]);
  scanf("%lld", &k);
  if (l[1] < l[2])
    min = l[2];
  else
    min = l[1];
  if (r[1] < r[2])
    max = r[1];
  else
    max = r[2];
  if (min <= max) {
    if (min <= k && k <= max)
      printf("%lld", max - min);
    else
      printf("%lld", max - min + 1);
  } else
    printf("0");
  return 0;
}
