#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T _abs(const T n) {
  return (n < 0 ? -n : n);
}
template <class T>
inline T _max(const T a, const T b) {
  return (!(a < b) ? a : b);
}
template <class T>
inline T _min(const T a, const T b) {
  return (a < b ? a : b);
}
template <class T>
inline void _setmax(T &a, const T b) {
  if (a < b) a = b;
}
template <class T>
inline void _setmin(T &a, const T b) {
  if (b < a) a = b;
}
template <class T>
inline T _sqr(const T x) {
  return x * x;
}
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int INF = 0x7f7f7f7f;
const int TMAX = 1 << 18;
int main() {
  long long l1, r1, l2, r2, k;
  scanf("%lld", &l1);
  scanf("%lld", &r1);
  scanf("%lld", &l2);
  scanf("%lld", &r2);
  scanf("%lld", &k);
  long long ans = r1 - l1 + 1, ans2;
  if (l2 > r1 || r2 < l1) {
    ans2 = 0;
  } else if (l2 <= l1 && r2 >= r1) {
    ans2 = r1 - l1 + 1;
    if (k >= l1 && k <= r1) {
      ans2--;
    }
  } else if (l1 <= l2 && r1 >= r2) {
    ans2 = r2 - l2 + 1;
    if (k >= l2 && k <= r2) {
      ans2--;
    }
  } else if (l2 >= l1) {
    ans2 = r1 - l2 + 1;
    if (k >= l2 && k <= r1) {
      ans2--;
    }
  } else {
    ans2 = r2 - l1 + 1;
    if (k >= l1 && k <= r2) {
      ans2--;
    }
  }
  printf("%lld\n", ans2);
}
