import sequtils,strutils type jump = tuple[one : int, two : int, three : int] const m = 1_000_000_007 var N,i,j : int procedure : seq[jump] pattern : jump procedure = @[(0,0,0),(1,0,0),(0,1,0),(1,1,1)] N = stdin.readline.parseInt if N < 3: echo 1 elif N == 3: echo 3 else: for i in 4..N: pattern.one = (procedure[i - 1].two + procedure[i - 1].three) mod m pattern.two = (procedure[i - 2].one + procedure[i - 2].three) mod m pattern.three = (procedure[i - 3].one + procedure[i - 3].two) mod m procedure.add(pattern) j = (procedure[N].one + procedure[N].two + procedure[N].three).int mod m echo j