#include <bits/stdc++.h>
using namespace std;
long long l1, r1, l2, r2, k;
int main(int argc, char** argv) {
  scanf("%I64d%I64d%I64d%I64d%I64d", &l1, &r1, &l2, &r2, &k);
  long long begin = (l1 > l2) ? l1 : l2;
  long long end = (r1 < r2) ? r1 : r2;
  long long time = end - begin + 1;
  if (time <= 0) {
    printf("0\n");
  } else {
    if (k >= begin && k <= end) {
      time--;
    }
    printf("%I64d\n", time);
  }
  return 0;
}
