通过枚举每一个组合,判断每个组合的每个位数是否符合要求,由于是圆盘,所以符合要求的条件可以有俩个,第一个为俩个数之间的差符合要求,第二个为俩个数所构成的区间的补集符合要求,取俩者之间的最小值,判断是否符合条件
a=int(input())
b=list(map(int,input().split()))
c=list(map(int,input().split()))
sum=0
def choose(x:int,y:int) ->bool:
d=min(abs(x-y),a-abs(x-y))
return d<=2
for i in range(1,a+1):
for l in range(1,a+1):
for t in range(1,a+1):
if choose(i,b[0])==True and choose(l,b[1])==True and choose(t,b[2])==True:
sum+=1
continue
if choose(i,c[0])==True and choose(l,c[1])==True and choose(t,c[2])==True:
sum+=1
print(sum)