#include <bits/stdc++.h>
using namespace std;
long long power(long long b, long long e, long long m) {
  if (e == 0) return 1;
  if (e & 1) return b * power(b * b % m, e / 2, m) % m;
  return power(b * b % m, e / 2, m);
}
long long power(long long b, long long e) {
  if (e == 0) return 1;
  if (e & 1) return b * power(b * b, e / 2);
  return power(b * b, e / 2);
}
void solve() {
  long long l1, r1, l2, r2, k;
  cin >> l1 >> r1 >> l2 >> r2 >> k;
  long long x = max(l1, l2);
  long long y = min(r1, r2);
  if (x <= y) {
    if (k >= x and k <= y)
      cout << y - x << "\n";
    else
      cout << y - x + 1 << "\n";
  } else
    cout << 0 << "\n";
}
int main() {
  long long t = 1;
  while (t--) solve();
  return 0;
}
