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