#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
int main() {
  long long l1, r1, l2, r2, k;
  cin >> l1 >> r1 >> l2 >> r2 >> k;
  long long ans;
  if (r1 <= r2) {
    if (r1 >= l2) {
      ans = r1 - max(l1, l2) + 1;
      if (max(l1, l2) <= k && k <= r1) ans--;
    } else
      ans = 0;
  } else {
    if (r2 >= l1) {
      ans = r2 - max(l1, l2) + 1;
      if (max(l1, l2) <= k && k <= r2) ans--;
    } else
      ans = 0;
  }
  cout << ans << endl;
  return 0;
}
