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