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