n,k=map(int,input().split())
def po(a,t,p):
    bi=str(format(t,"b"))#2進表現に
    res=1
    for i in range(len(bi)):
    res=(res*res) %p
        if bi[i]=="1":
          res=(res*a) %p
    return res
print(po(2,n+1,1000000007)-po(2,k-1,1000000007))