unittest
{
	assert( [ "8" ].parse.expand.solve == 10 );
	assert( [ "1000000000000" ].parse.expand.solve == 2499686339916 );
}



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

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

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	return tuple( n );
}

auto solve( long n )
{
	auto ans = 0L;
	for( auto d = 1L; d <= n ^^ 0.5L; d++ )
	{
		// n / m == d になるmの範囲を計算
		auto l = n / ( d + 1 );
		auto r = n / d;
		
		// n % m == d になるmを二分探索
		auto m = ( l + r ) / 2;
		while( l < m && m < r )
		{
			auto a = n % m;
			if( a == d )
			{
				ans += m;
				break;
			}
			if( a < d ) r = m;
			else        l = m;
			m = ( l + r ) / 2;
		}
	}
	return ans;
}
