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