#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  long long l1, r1, l2, r2, k;
  cin >> l1 >> r1 >> l2 >> r2 >> k;
  if (l1 <= l2 && r2 <= r1) {
    cout << r2 - l2 + 1 - (k >= l2 && k <= r2) << endl;
  } else if (r2 >= l1 && r2 <= r1) {
    cout << r2 - l1 + 1 - (k >= l1 && k <= r2) << endl;
  } else if (l2 <= r1 && l2 >= l1) {
    cout << r1 - l2 + 1 - (k >= l2 && k <= r1) << endl;
  } else if (l2 <= l1 && r1 <= r2) {
    cout << r1 - l1 + 1 - (k >= l1 && k <= r1) << endl;
  } else if (r1 >= l2 && r1 <= r2) {
    cout << r1 - l2 + 1 - (k >= l2 && k <= r1) << endl;
    cout << "asd" << endl;
  } else if (l1 <= r2 && l1 >= l2) {
    cout << r2 - l1 + 1 - (k >= l1 && k <= r2) << endl;
  } else {
    cout << 0 << endl;
  }
}
