unittest
{
	assert( [ "3 2" ].parse.expand.solve == 1 );
	assert( [ "3 1" ].parse.expand.solve == 0 );
	assert( [ "8 5" ].parse.expand.solve == 3 );
}



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 nk = input.front.split.to!( long[] );
	return tuple( nk[ 0 ], nk[ 1 ] );
}

auto solve( long n, long k )
{
	return ( k == 1 ) ? 0L : ( n - k );
}
