#include <bits/stdc++.h>
using namespace std;
int n, m;
int main() {
  long long l1, r1, l2, r2, k;
  while (cin >> l1 >> r1 >> l2 >> r2 >> k) {
    long long ansl = max(l1, l2), ansr = min(r1, r2);
    if (ansr < ansl)
      cout << 0 << endl;
    else if (k >= ansl && k <= ansr)
      cout << ansr - ansl << endl;
    else
      cout << ansr - ansl + 1 << endl;
  }
  return 0;
}
