Buggy python submission (verdict: Time Limit Exceeded):
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
import collections
N,M = [int(x) for x in input().split()]
ans =[0]*N
for i in range (M):
    L,R = [int(x) for x in input().split()]
    ans[L-1:R] = map(lambda x: x+1, ans[L-1:R] )



       

print(ans.count(M))







Fixed submission:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N,M = [int(x) for x in input().split()]
Llist =[]
Rlist =[]
for i in range (M):
    L,R = [int(x) for x in input().split()]
    Llist.append(L)
    Rlist.append(R)
 
lmax = max(Llist)
Rmax = min(Rlist)

if lmax > Rmax:
    print(0)
else:
    print(Rmax-lmax+1)

Buggy python submission (verdict: Time Limit Exceeded):
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
import collections
N,M = [int(x) for x in input().split()]
ans =[0]*N
for i in range (M):
    L,R = [int(x) for x in input().split()]
    ans[L-1:R] = map(lambda x: x+1, ans[L-1:R] )

count = 0
for i in ans:
    if i == M :
        count+= 1

       

print(count)







Fixed submission:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N,M = [int(x) for x in input().split()]
Llist =[]
Rlist =[]
for i in range (M):
    L,R = [int(x) for x in input().split()]
    Llist.append(L)
    Rlist.append(R)
 
lmax = max(Llist)
Rmax = min(Rlist)

if lmax > Rmax:
    print(0)
else:
    print(Rmax-lmax+1)

Buggy python submission (verdict: Time Limit Exceeded):
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
import collections
N,M = [int(x) for x in input().split()]
idls =[]
for i in range(N):
    idls.append(i+1)
ans =[]
LR =[]
for i in range (M):
    L,R = [int(x) for x in input().split()]
    LR.append((L,R))

for i in range (M):
    
    iidls = idls[LR[i][0]-1:LR[i][1]]
    ans+=iidls
c= collections.Counter(ans)

a = c.most_common()

count = 0
for i in a:
    if i[1] == M:
        count+= 1
       

print(count)







Fixed submission:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N,M = [int(x) for x in input().split()]
Llist =[]
Rlist =[]
for i in range (M):
    L,R = [int(x) for x in input().split()]
    Llist.append(L)
    Rlist.append(R)
 
lmax = max(Llist)
Rmax = min(Rlist)

if lmax > Rmax:
    print(0)
else:
    print(Rmax-lmax+1)

Buggy python submission (verdict: Time Limit Exceeded):
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
import collections
N,M = [int(x) for x in input().split()]
idls =[]
for i in range(N):
    idls.append(i+1)
ans =[]
for i in range (M):
    L,R = [int(x) for x in input().split()]
    iidls = idls[L-1:R]
    ans+=iidls
c= collections.Counter(ans)

a = c.most_common()

count = 0
for i in a:
    if i[1] == M:
        count+= 1
       

print(count)







Fixed submission:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N,M = [int(x) for x in input().split()]
Llist =[]
Rlist =[]
for i in range (M):
    L,R = [int(x) for x in input().split()]
    Llist.append(L)
    Rlist.append(R)
 
lmax = max(Llist)
Rmax = min(Rlist)

if lmax > Rmax:
    print(0)
else:
    print(Rmax-lmax+1)

Buggy python submission (verdict: Runtime Error):
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
import collections
N,M = [int(x) for x in input().split()]
idls =[]
for i in range(N):
    idls.append(i+1)
ans =[]
for i in range (M):
    L,R = [int(x) for x in input().split()]
    iidls = idls[L-1:R]
    ans+=iidls
c= collections.Counter(ans)

a = c.most_common()

counter = 0
count = 0
while True:
    if a[counter][1] == M:
        count+=1
        counter +=1
        if counter == N:
            break
    else:
        break

print(count)







Fixed submission:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N,M = [int(x) for x in input().split()]
Llist =[]
Rlist =[]
for i in range (M):
    L,R = [int(x) for x in input().split()]
    Llist.append(L)
    Rlist.append(R)
 
lmax = max(Llist)
Rmax = min(Rlist)

if lmax > Rmax:
    print(0)
else:
    print(Rmax-lmax+1)

Buggy python submission (verdict: Time Limit Exceeded):
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N,M = [int(x) for x in input().split()]
idls =[]
for i in range(N):
    idls.append(i+1)
ans =[]
for i in range (M):
    L,R = [int(x) for x in input().split()]
    iidls = set(idls[L-1:R])
    ans.append( iidls)


s = ans[0]
for i in range(M-1):
    s1 = s.intersection(ans[i+1])
    s = s1

print(len(s))







Fixed submission:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N,M = [int(x) for x in input().split()]
Llist =[]
Rlist =[]
for i in range (M):
    L,R = [int(x) for x in input().split()]
    Llist.append(L)
    Rlist.append(R)
 
lmax = max(Llist)
Rmax = min(Rlist)

if lmax > Rmax:
    print(0)
else:
    print(Rmax-lmax+1)

Buggy python submission (verdict: Time Limit Exceeded):
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N,M = [int(x) for x in input().split()]
idls =[]
for i in range(N):
    idls.append(i+1)
ans =[]
for i in range (M):
    L,R = [int(x) for x in input().split()]
    iidls = idls[L-1:R]
    ans += iidls

count = 0
for i in range (N):
    a = ans.count(i+1)
    if a == M:
        count+=1

print(count)







Fixed submission:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N,M = [int(x) for x in input().split()]
Llist =[]
Rlist =[]
for i in range (M):
    L,R = [int(x) for x in input().split()]
    Llist.append(L)
    Rlist.append(R)
 
lmax = max(Llist)
Rmax = min(Rlist)

if lmax > Rmax:
    print(0)
else:
    print(Rmax-lmax+1)