#include <bits/stdc++.h>
using namespace std;
int main() {
  uint64_t l1, r1, l2, r2, k;
  cin >> l1 >> r1 >> l2 >> r2 >> k;
  uint64_t maxL = max(l1, l2);
  uint64_t minR = min(r1, r2);
  uint64_t result =
      (minR - maxL + 1) * (maxL <= minR) - 1 * (maxL <= k) * (k <= minR);
  cout << result << endl;
  return 0;
}
