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