#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int L1, R1, L2, R2, K;
  cin >> L1 >> R1 >> L2 >> R2 >> K;
  long long int L = max(L1, L2), R = min(R1, R2);
  if (L > R) {
    cout << 0 << endl;
    return 0;
  }
  if (K <= R && K >= L)
    cout << R - L << endl;
  else
    cout << R - L + 1 << endl;
}
