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