#include <bits/stdc++.h>
using namespace std;
const long long N = 2e6 + 5, MOD = 1e6 + 3, MAXN = 1e5, LG = 20, M = 1e7,
                P = 727, Sq = 100;
const long long inf = 1e18 + 10;
int32_t main() {
  long long l1, r1, l2, r2, k, ans = 0;
  cin >> l1 >> r1 >> l2 >> r2 >> k;
  if (l1 > l2) {
    swap(l1, l2);
    swap(r1, r2);
  }
  if (l2 <= r1)
    ans = min(r1, r2) - l2 + 1;
  else
    ans = 0;
  if (k >= l2 && k <= min(r1, r2)) ans--;
  return cout << ans, 0;
}
