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