program kokoso_riesutai;
  { 40 u‘davinys }

  function surinkta (n : integer) : integer;
    var gerai,
        rasta : boolean; { ar rastas sprendinys }
        m, ries, { surinkt— riežut— skai‡ius }
        i, { bendrakeleivio numeris }
        k : integer;
  begin
    rasta := false;
    k := 0;
    while not rasta do { perrinksime k variantus }
      begin
        k := k + 1;
        m := k * n + 1;
        ries := m;
        gerai := true;
        i := 1;
        while gerai and (i <= n) do
        { tikrinama, ar tinka parinktas variantas }
          begin
            if (m - 1) mod n <> 0
               then gerai := false
               else m := m - (m - 1) div n - 1;
            i := i + 1;
          end;
        rasta := gerai and (m > 0) and (m mod n = 0)
      end;
    surinkta := ries
  end;

  var n : integer;
begin
  readln (n);
  writeln (surinkta (n));
end.

