#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long l1, r1, l2, r2, k;
  cin >> l1 >> r1 >> l2 >> r2 >> k;
  unsigned long long delta = min(r1, r2) - max(l2, l1) + 1;
  if (k >= max(l1, l2) && k <= min(r1, r2)) delta--;
  if (r1 < l2 || r2 < l1) {
    printf("0\n");
  } else {
    cout << delta << endl;
  }
}
