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