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