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