#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int i, n, a, b, c, d, k, ans = 0, l, r;
  cin >> a >> b >> c >> d >> k;
  l = max(a, c);
  r = min(b, d);
  if (l > r)
    cout << "0" << endl;
  else {
    ans = r - l + 1;
    if (c <= k && k <= d && (a <= k && k <= b)) ans--;
    cout << ans << endl;
  }
  return 0;
}
