Today an outstanding event is going to happen in the forest — hedgehog Filya will come to his old fried Sonya!

Sonya is an owl and she sleeps during the day and stay awake from minute l_1 to minute r_1 inclusive. Also, during the minute k she prinks and is unavailable for Filya.

Filya works a lot and he plans to visit Sonya from minute l_2 to minute r_2 inclusive.

Calculate the number of minutes they will be able to spend together.


-----Input-----

The only line of the input contains integers l_1, r_1, l_2, r_2 and k (1 ≤ l_1, r_1, l_2, r_2, k ≤ 10^18, l_1 ≤ r_1, l_2 ≤ r_2), providing the segments of time for Sonya and Filya and the moment of time when Sonya prinks.


-----Output-----

Print one integer — the number of minutes Sonya and Filya will be able to spend together.


-----Examples-----
Input
1 10 9 20 1

Output
2

Input
1 100 50 200 75

Output
50



-----Note-----

In the first sample, they will be together during minutes 9 and 10.

In the second sample, they will be together from minute 50 to minute 74 and from minute 76 to minute 100.

Difficulty: interview

Starter code:

Solutions:
read = lambda: list(map(int, input().split()))
l1, r1, l2, r2, k = read()
R = min(r1, r2)
L = max(l1, l2)
ans = max(R - L + 1, 0)
if L <= k <= R: ans = max(ans - 1, 0)
print(ans)


l1,r1,l2,r2,k = (int(i) for i in input().split())
l = max(l1,l2)
r = min(r1,r2)
if r < l:
    print(0)
else:
    ans = r-l
    if k >= l and k <= r:
        print(ans)
    else:
        print(ans+1)

from math import *
a, b, c, d, k = map(int, input().split())
per1 = max(a, c)
per2 = min(b, d)
if per2 >= per1:
    if per1<=k<=per2:
        print(per2 - per1)
    else:
        print(per2 - per1 + 1)
else:
    print(0)

import sys, math
l1, r1, l2, r2, k = map(int,input().split())
a = max(l1, l2)
b = min(r1, r2)
ans = b - a + 1
if a <= k <= b:
    ans -= 1
print(max(0, ans))

l1,r1,l2,r2,k = list(map(int, input().split()))

if r1 < l2:
    print(0)
elif r2 < l1:
    print(0)
else:
    l = max(l1, l2)
    r = min(r1, r2)
    if k < l or k > r:
        print(r - l + 1)
    else:
        print(r - l + 1 - 1)


l1, r1, l2, r2, k = map(int, input().split())
l = l1
if l2 > l:
	l = l2
r = r1
if r2 < r:
	r = r2
if r < l:
	print(0)
elif l <= k <= r:
	print(r - l)
else:
	print(r - l + 1)

l1, r1, l2, r2, k = map(int, input().split())
lmax = max(l1, l2)
rmin = min(r1, r2)

if lmax > rmin:
    print(0)
else:
    ans = rmin - lmax + 1
    if k >= lmax and k <= rmin:
        ans -= 1
    print(ans)

l_1, r_1, l_2, r_2, k = map(int, input().split())
left = max(l_1, l_2)
right = min(r_1, r_2)
if left > right:
    print(0)
else:
    if left <= k <= right:
        print(right - left)
    else:
        print(right - left + 1)

from sys import stdout
a,b,c,d,e = [int(i) for i in input().split()]
t = max(a,c)
t1= min(b,d)
if t <= t1:
	if t<=e and e<=t1:
		print(t1-t)
	else:
		print(t1-t+1)
else:
	print(0)


l1, r1, l2, r2, k = map(int, input().split())
ans = max(0, min(r1, r2) - max(l1, l2) + 1)
if max(l1, l2) <= k <= min(r1, r2):
    ans = max(ans - 1, 0)
print(ans)

i = input().split()
start = max(int(i[0]), int(i[2]))
end = min(int(i[1]), int(i[3]))
res = end - start + 1
if start <= int(i[4]) <= end:
    res -= 1
if res < 0:
    res = 0
print(res)


3

left1, right1, left2, right2, k = list(map(int, input().split()))

intersection_left = max(left1, left2)
intersection_right = min(right1, right2)

answer = 0
if intersection_right >= k >= intersection_left:
    answer -= 1

if intersection_right >= intersection_left:
    answer += intersection_right - intersection_left + 1

print(answer)


l_1, r_1, l_2, r_2, k = list(map(int, input().split()))
ans = min(r_1, r_2) - max(l_1, l_2) + 1
if max(l_1, l_2) <= k <= min(r_1, r_2):
    ans -= 1
if ans < 0:
    ans = 0
print(ans)


l1, r1, l2, r2, k = list(map(int, input().split()))
l = max(l1, l2)
r = min(r1, r2)
ans = max(r - l + 1, 0)
if k >= l and k <= r:
	ans -= 1
print(ans)



l1, r1, l2, r2, k = list(map(int, input().split()))

a = b = -1
if l1 <= l2 and r2 <= r1:
    a, b = l2, r2
elif l2 <= l1 and r1 <= r2:
    a, b = l1, r1
elif l1 <= l2 <= r1:
    a, b = l2, r1
elif l1 <= r2 <= r1:
    a, b = l1, r2

if a == -1 or b == -1:
    print(0)
else:
    res = b - a + 1
    if a <= k <= b:
        res -= 1
    print(res)


l1,r1,l2,r2,k = list(map(int,input().split()))
if l1 > r2 or r1 < l2:
    print(0)
    return
ml = max(l1,l2)
mr = min(r1,r2)
delta = 1 if ml<=k<=mr else 0
print(abs(mr-ml)+1-delta)


temp=input().split()
l1=int(temp[0])
r1=int(temp[1])
l2=int(temp[2])
r2=int(temp[3])
k=int(temp[4])

t=0

l = max(l1,l2)
r = min(r1,r2)

if r>=l:
	t+=(r-l+1)

if l<=k and k<=r:
	t-=1

print(t)


def solve():
    l1, r1, l2, r2, k = list(map(int, input().split(' ')))

    start = max(l1, l2)
    end = min(r1, r2)

    ans = max(0, end - start + 1)

    if start <= k <= end:
        ans -= 1

    print(ans)


def main():
    solve()

def __starting_point():
    main()

__starting_point()

l1, r1, l2, r2, k = list(map(int, input().split()))
if l1 >= l2 and r1 <= r2:
    if l1 <= k and r1 >= k:
        print(r1 - l1)
    else:
        print(r1 - l1 + 1)
elif l2 >= l1 and r2 <= r1:
    if l2 <= k and r2 >= k:
        print(r2 - l2)
    else:
        print(r2 - l2 + 1)
elif l1 <= l2 and l2 <= r1 and r1 <= r2:
    if l2 <= k and r1 >= k:
        print(r1 - l2)
    else:
        print(r1 - l2 + 1)
elif l2 <= l1 and l1 <= r2 and r2 <= r1:
    if l1 <= k and r2 >= k:
        print(r2 - l1)
    else:
        print(r2 - l1 + 1)
else:
    print(0)


import sys

def main():
    l1, r1, l2, r2, k = [int(i) for i in sys.stdin.readline().strip().split()]
    l = max(l1, l2)
    r = min(r1, r2)
    if l <= r:
        print(r - l + 1 - (1 if l <= k <= r else 0))
    else:
        print(0)

def __starting_point():
    main()
__starting_point()

#!/usr/local/env python3
# -*- encoding: utf-8 -*-
import sys


def readnlines(f_in):
    n = int(f_in.readline().strip())
    m = []
    for i in range(n):
        line = f_in.readline().strip()
        if line.isdigit():
            m.append(int(line))
        else:
            m.append(line)
    return m


def print_args():
    print("Recieved {} arguments = {}.".format(len(sys.argv), sys.argv))


def intersect(l1, r1, l2, r2):
    left = max(l1, l2)
    right = min(r1, r2)
    return left, right, max(0, right - left + 1)


def solve():
#    print_args()
    # m = readnlines(sys.stdin)
    line = sys.stdin.readline().strip()
    l1, r1, l2, r2, k = [int(i) for i in line.split()]
    left, right, inters = intersect(l1, r1, l2, r2)
    #print("left={}, right={}, intesec={}".format(left, right, inters))
    if inters < 1:
        return 0
    else:
        if (k >= left) and (k <= right):
            return inters - 1
        else:
            return inters


def __starting_point():
   ans = solve()
   print(ans)

__starting_point()

l1, r1, l2, r2, k = map(int, input().split())

answer = min(r1, r2) - max(l1, l2) + 1

if min(r1, r2) >= k >= max(l1, l2):
    answer -= 1

print(max(0, answer))

l1, r1, l2, r2 , k = map(int, input().split())

l = max(l1,l2)
r = min(r1,r2)
count = max(r - l + 1, 0)

if l <= k <= r:
    count -= 1
print(count)

# You lost the game.

l1,r1,l2,r2,k = list(map(int, input().split()))

"""if l1 > l2:
    r = min(r1,r2)-l1+1
    if k >= l1 and k <= min(r1,r2):
        r -= 1
elif l2 > l1:
    r = min(r1,r2)-l2+1
    if k >= l2 and k <= min(r1,r2):
        r -= 1
else:
    r = min(r1,r2)-l1
    if k >= l1 and k <= min(r1,r2):
        r -= 1"""
l = max(l1,l2)
r = min(r1,r2)
res = r-l+1
if k >= l and k <= r:
    res -= 1
print(max(0,res))


l1, r1, l2, r2, k  = map(int, input().split())
start = max(l1, l2)
end = min(r1, r2)
if start <= k <= end:
	print(end - start)
elif start <= end:
	print(end - start + 1)
else:
	print(0)