unittest
{
	assert( [ "6" ].solve == 3 );
	assert( [ "3141" ].solve == 13 );
	assert( [ "314159265358" ].solve == 9 );
}



import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	
	// nをkでx回割った後にkをy回引いて1になるkをカウント
	auto ans = 0L;
	foreach( k; n.divisors )
	{
		if( k == 1 ) continue;
		auto m = n;
		while( m % k == 0 ) m /= k;
		if( m - k * ( m / k ) == 1 ) ans++;
	}
	
	// kをy回引いて1になるkをカウント
	foreach( k; ( n - 1 ).divisors )
	{
		if( k == 1 ) continue;
		ans++;
	}
	return ans;
}

// 約数列挙
auto divisors( long n )
{
	bool[ long ] ds;
	auto s = cast( long ) n ^^ 0.5L;
	for( auto i = 1L; i <= s; i++ )
	{
		if( n % i != 0 ) continue;
		ds[ i     ] = true;
		ds[ n / i ] = true;
	}
	return ds.keys;
}
