Module Collatz
    Function Collatz(ByVal i As Long)
        Dim cnt As Long
        cnt = 0
        While i <> 1
            cnt += 1
            If i Mod 2 = 0 Then
                i \= 2
            Else
                i *= 3
                i += 1
            End If
        End While
        Return cnt
    End Function

    Sub Main(ByVal args() as String)
        Dim n, i, acc As Long
        n = Console.ReadLine()
        acc = 0
        For i=1 to n
            acc += Collatz(i)
            acc = acc Mod 1000000007
        Next
        Console.WriteLine(acc)
    End Sub
End Module
