#include <bits/stdc++.h>
using namespace std;
int main() {
  long long l[2], r[2], k;
  cin >> l[0] >> r[0] >> l[1] >> r[1] >> k;
  long long max_ow = min(r[0], r[1]);
  long long min_ow = max(l[0], l[1]);
  long long ans = max_ow - min_ow;
  if (max_ow >= k && min_ow <= k) {
    ans--;
  }
  if (ans < 0) {
    cout << "0" << endl;
    return 0;
  }
  cout << ans + 1 << endl;
  return 0;
}
