#include <bits/stdc++.h>
using namespace std;
long long l1, r1, l2, r2, k;
long long ans;
int32_t main() {
  ios_base::sync_with_stdio(false);
  if (fopen("cf714a.in", "r")) {
    freopen("cf714a.in", "r", stdin);
    freopen("cf714a.out", "w", stdout);
  }
  cin >> l1 >> r1 >> l2 >> r2 >> k;
  if (l1 < l2) {
    if (r1 < r2) {
      ans += r1 - l2 + 1;
      if (l2 <= k && k <= r1) {
        ans--;
      }
    } else {
      ans += r2 - l2 + 1;
      if (l2 <= k && k <= r2) {
        ans--;
      }
    }
  } else {
    if (r1 < r2) {
      ans += r1 - l1 + 1;
      if (l1 <= k && k <= r1) {
        ans--;
      }
    } else {
      ans += r2 - l1 + 1;
      if (l1 <= k && k <= r2) {
        ans--;
      }
    }
  }
  cout << max(ans, 0ll) << '\n';
  return 0;
}
