program substring
  implicit none
  character(1000) :: s, t
  integer :: ns, nt, d = 1e9, x, i, j
  read(*,*) s
  read(*,*) t
  ns = len_trim(s)
  nt = len_trim(t)
  do i = 1, ns - nt + 1
    x = 0
    do j = 1, nt
      if (s(i + j - 1:i + j - 1) /= t(j:j)) x = x + 1
    end do
    d = min(d, x)
  end do
  write(*,'(i0)') d
end program substring