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