#include <bits/stdc++.h>
using namespace std;
long long l1, r1, l2, r2, k;
void doc() { cin >> l1 >> r1 >> l2 >> r2 >> k; }
void xl() {
  long long ans;
  ans = min(r1, r2) - max(l1, l2) + 1;
  if (k >= max(l1, l2) and k <= min(r1, r2)) ans--;
  ans = max(ans, (long long)0);
  cout << ans;
}
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  doc();
  xl();
}
