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