input();c=1;A=0 for x in input()[::-1]:A+=A+(c!=(c:=c^64^ord(x)or c)) print(A%(10**9+7))