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