#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
template < class T, class T2> inline void chkmax( T & x, const T2 & y) { if ( x < y) x = y; }
template < class T, class T2> inline void chkmin( T & x, const T2 & y) { if ( x > y) x = y; }
const int MAXN = ( 1 << 20 ) ;
const int mod = ( int ) 1e9 + 7 ;
int64_t n;
void read( )
{
cin >> n;
}
vector< int > li;
int a[ MAXN] ;
int pw( int x, int64_t p)
{
int ret = 1 ;
while ( p)
{
if ( p & 1ll) ret = ( ret * 1ll * x) % mod;
p >>= 1ll;
x = ( x * 1ll * x) % mod;
}
return ret;
}
int64_t cnt[ MAXN] ;
void solve( )
{
vector< int64_t > li;
for ( int64_t d = 1 ; d * 1ll * d <= n; d++ )
if ( n % d == 0 )
{
li.push_back ( d) ;
li.push_back ( n / d) ;
}
sort( li.begin ( ) , li.end ( ) ) ;
li.erase ( unique( li.begin ( ) , li.end ( ) ) , li.end ( ) ) ;
memset ( cnt, 0 , sizeof ( cnt) ) ;
int64_t answer = n % mod;
int po = 0 ;
for ( int64_t l: li)
{
po++ ;
if ( l == 1 || l == n) continue ;
int64_t p = ( ( n / l - 1 ) % mod) ;
cnt[ po - 1 ] = ( pw( 2 , l) + mod - 2ll) % mod;
for ( int i = po - 2 ; i >= 0 ; i-- )
if ( l % li[ i] == 0 )
cnt[ po - 1 ] = ( cnt[ po - 1 ] - cnt[ i] + mod) % mod;
p = ( p * 1ll * cnt[ po - 1 ] ) % mod;
answer = ( answer + p) % mod;
}
cout << answer << endl;
}
int main( )
{
freopen ( "gymnasts.in" , "r" , stdin ) ;
freopen ( "gymnasts.out" , "w" , stdout ) ;
ios_base:: sync_with_stdio ( false ) ;
cin .tie ( NULL ) ;
read( ) ;
solve( ) ;
return 0 ;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgZW5kbCAnXG4nCgp1c2luZyBuYW1lc3BhY2Ugc3RkOwp0ZW1wbGF0ZTxjbGFzcyBULCBjbGFzcyBUMj4gaW5saW5lI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