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