#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  long long l1, r1, l2, r2, k;
  cin >> l1 >> r1 >> l2 >> r2 >> k;
  long long ans = 0;
  if (l1 <= k and k <= r1) {
    if (l1 <= k - 1) {
      ans += max(0ll, min(r2, k - 1) - max(l2, l1) + 1);
    }
    if (k + 1 <= r1) {
      ans += max(0ll, min(r2, r1) - max(l2, k + 1) + 1);
    }
  } else {
    ans = max(0ll, min(r1, r2) - max(l1, l2) + 1);
  }
  cout << ans << endl;
  return 0;
};
