#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
int main() {
  long long a, b, c, d, e, ans = 0;
  cin >> a >> b >> c >> d >> e;
  long long l = max(a, c), r = min(b, d);
  if (e >= l && e <= r) ans++;
  cout << max(0LL, (r - l + 1 - ans));
}
