#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c, d, k;
  while (~scanf("%lld %lld %lld %lld %lld", &a, &b, &c, &d, &k)) {
    long long s = min(b, d) - max(a, c) + 1;
    if (k <= min(b, d) && k >= max(a, c)) s--;
    printf("%lld\n", s > 0 ? s : 0);
  }
  return 0;
}
