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