n = int(input()) mat = [[0,0,1],[1,0,0],[1,1,0]] mod = 1000000007 ret = [[1,0,0],[0,1,0],[0,0,1]] while n>0 : if (n&1) == 1 : tmp = [[0,0,0],[0,0,0],[0,0,0]] for i in range(3) : for k in range(3) : for j in range(3) : tmp[i][j] += ret[i][k] * mat[k][j] if tmp[i][j] >= mod : tmp[i][j] %= mod ret = tmp tmp_ = [[0,0,0],[0,0,0],[0,0,0]] for i in range(3) : for k in range(3) : for j in range(3) : tmp_[i][j] += mat[i][k] * mat[k][j] if tmp_[i][j] >= mod : tmp_[i][j] %= mod mat = tmp_ n = n>>1 ans = (ret[0][2] + ret[1][2] + ret[2][2]) % mod print(ans)