#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c, d, k;
  cin >> a >> b >> c >> d >> k;
  if ((b < c) or (a > d)) {
    cout << 0;
    return 0;
  }
  if (max(a, c) <= k and min(b, d) >= k) {
    cout << min(b, d) - max(a, c);
    return 0;
  } else {
    cout << min(b, d) - max(a, c) + 1;
    return 0;
  }
}
