N := 123456; S := IntToStr(N); N := 0; for i := Length(S) downto 1 do if S[i] = '3' then begin N := i; break; end; WriteLn(N);