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