#include <bits/stdc++.h>
using namespace std;
int main() {
  long long l1, r1, l2, r2, k;
  while (cin >> l1 >> r1 >> l2 >> r2 >> k) {
    long long ans = 0;
    ans =
        min(r2, r1) - max(l1, l2) + 1 - (k <= min(r2, r1) && k >= max(l1, l2));
    cout << max(ans, 0ll) << endl;
  }
}
