#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int l1, l2, r1, r2, k;
  cin >> l1 >> r1 >> l2 >> r2 >> k;
  long long int tm = 0;
  if (l1 > l2) {
    swap(l1, l2);
    swap(r1, r2);
  }
  if (l1 <= l2 && r2 <= r1) {
    tm = (r2 - l2 + 1);
    if (k >= l2 && k <= r2) tm -= 1;
  } else if (l2 > r1) {
    tm = 0;
  } else if (l2 <= r1) {
    tm = r1 - l2 + 1;
    if (k >= l2 && k <= r1) tm -= 1;
  }
  cout << max(tm, (long long)0) << endl;
  return 0;
}
