with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Solve is
   X : Integer;
   A : Integer;
   B : Integer;
begin
   Get (X);
   Get (A);
   Get (B);
   X := X-A;
   Put_Line (Integer'Image (X-X/B*B));
end Solve;