var
  f,g:text;
  s:string;
  k,i:integer;
begin
  assign(f,'input.txt');
  assign(g,'output.txt');
  reset(f);
  rewrite(g);
  readln(f,s);
  k:=0;
  for i:=1 to length(s) do
    begin
      k:=k+ord(s[i])-ord('0');
      k:=k mod 9;
    end;
  if k=0 then k:=9;   
  writeln(g,k);
  close(f);
  close(g);

end.
