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