#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  long long l, r, L, R, k;
  cin >> l;
  cin >> r;
  cin >> L;
  cin >> R;
  cin >> k;
  long long del, ans = 0;
  if (l <= L && L <= r) {
    long long end = min(r, R);
    ans = end - L + 1;
    if (k >= L && k <= end) ans--;
  }
  if (L <= l && l <= R) {
    long long end = min(r, R);
    ans = end - l + 1;
    if (k >= l && k <= end) ans--;
  }
  cout << ans;
  cout << endl;
  return 0;
}
