program main use iso_fortran_env implicit none integer(int32)::ans,i character(100)::s read"(A)",s ans=0 do i=1,len_trim(S) ans=ans+ichar(S(i:i))-ichar("0") end do print"(i0)",ans end program main