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