{
TASK: LOSIMAS
LANG: PASCAL
}


program losejas;
  uses zaisti;
  var didsuma, suma : longint;
      pr_ejimas, mano_ejimas : integer;
  function versti (svetimas : byte; suma, didsuma : longint) : byte;
    var mod7 : longint;
  begin
    mod7 := (didsuma - suma) mod 7;
    if mod7 <> 0
      then if mod7 = svetimas
        then if mod7 mod 2 = 0
          then versti := mod7 div 2
          else versti := (mod7 + 7) div 2
        else versti := mod7
      else versti := 7 - svetimas;
  end;
begin
  init (didsuma, pr_ejimas);
  suma := pr_ejimas;
  while true do
    begin
      mano_ejimas := versti (pr_ejimas, suma, didsuma);
      suma := suma + mano_ejimas;
      eiti (mano_ejimas, pr_ejimas);
      suma := suma + pr_ejimas;
    end;
end.
