program sample
    implicit none
    character(100)::s
    integer(8) :: i,j,m,n,x(26),y(26),z(26),a,b
  
    read(*,*) s
    n=len_trim(s)
    x(:)=0
    y(:)=-1
    do i=1,n
        x(:)=x(:)+1
        a=ichar(s(i:i))-96 
        x(a)=x(a)-1
        y(a)=max(x(a),y(a))
        x(a)=0
    end do
    do i=1,26
        y(i)=max(x(i),y(i))
    end do
    write(*,*)minval(y)
    
    stop
end program sample
  

