#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int l1, l2, r1, r2, k, a, b, c = 0, d = 0;
  scanf("%I64d", &l1);
  scanf("%I64d", &r1);
  scanf("%I64d", &l2);
  scanf("%I64d", &r2);
  scanf("%I64d", &k);
  a = max(l1, l2);
  b = min(r1, r2);
  if (k >= a && k <= b) c = 1;
  cout << max(d, b - a + 1 - c);
  return 0;
}
