#include <bits/stdc++.h>
using namespace std;
int main() {
  long long l1, r1, l2, r2, k, x1, y, temp = 0;
  cin >> l1 >> r1 >> l2 >> r2 >> k;
  if (l1 > l2)
    x1 = l1;
  else
    x1 = l2;
  if (r1 < r2)
    y = r1;
  else
    y = r2;
  if (k >= x1 && k <= y)
    cout << y - x1;
  else if (y - x1 < 0)
    cout << 0;
  else
    cout << y - x1 + 1;
  return 0;
}
