main = getLine >> interact (show . g 1 . f)
 
f [] = []
f [x] = [1]
f (x:y:zs)
  | x == y = 0 : f zs
  | otherwise = 1 : f (y:zs)
 
g p [0] = p *% 6
g p [1] = p *% 3
g p (0:0:zs) = g (p *% 3) (0:zs)
g p (1:0:zs) = g p (0:zs)
g p (_:1:zs) = g (p *% 2) (1:zs)
 
(*%) = (`mod` 1000000007) $ (*)