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