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