a=int(input()) b=int(input()) cnt=0 maxn=0 for i in range(3): t=0 t=int(input()) cnt+=t if cnt>=maxn: maxn=cnt print(maxn)