unittest
{
	assert( [ "1234", "150", "100" ].parse.expand.solve == 84 );
	assert( [ "1000", "108", "108" ].parse.expand.solve == 28 );
	assert( [ "579", "123", "456" ].parse.expand.solve == 0 );
	assert( [ "7477", "549", "593" ].parse.expand.solve == 405 );
}



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

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

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto x = input.front.strip.to!( long );
	input.popFront;
	auto a = input.front.strip.to!( long );
	input.popFront;
	auto b = input.front.strip.to!( long );
	return tuple( x, a, b );
}

auto solve( long x, long a, long b )
{
	return ( x - a ) % b;
}
