#include <bits/stdc++.h>
using namespace std;
const long long Maxn3 = 1e3 + 10;
const long long Maxn4 = 1e4 + 10;
const long long Maxn5 = 1e5 + 10;
const long long Maxn6 = 1e6 + 10;
const long long Maxn7 = 1e7 + 10;
const long long Maxn8 = 1e8 + 10;
const long long Maxn9 = 1e9 + 10;
const long long Maxn18 = 1e18 + 10;
const long long Mod1 = 1e7 + 7;
const long long Mod2 = 1e9 + 7;
int main() {
  std::ios_base::Init i;
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  long long l1, r1, l2, r2, k, ans = 0;
  cin >> l1 >> r1 >> l2 >> r2 >> k;
  long long a = min(r1, r2), b = max(l1, l2);
  ans = a - b + 1;
  if (k >= b and k <= a) ans -= 1;
  if (ans >= 0)
    return cout << ans << endl, 0;
  else
    return cout << 0 << endl, 0;
}
