#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void gn(T &x) {
  x = 0;
  T f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
template <typename T>
inline void gt(T x) {
  if (!x) return;
  gt(x / 10);
  putchar(x % 10 + '0');
}
const long long maxn = 5e2 + 5;
long long t, n, m, q, ans;
long long MOD = 1e9 + 7, inf = 0x1f1f1f1f;
double eps = 1e-5;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long i, j, k, l, ca = 0, u, v;
  cin >> n >> m >> u >> v >> k;
  if (v < n || u > m)
    ans = 0;
  else {
    i = max(n, u);
    j = min(m, v);
    ans = j - i + 1 - (k >= i && k <= j);
  }
  cout << ans << endl;
  return 0;
}
