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