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