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