program main implicit none character*100000::S integer::len,wpos,cnum,wnum read *,S len = LEN_TRIM(S) wpos = SCAN(TRIM(S), 'w') cnum = wpos-1 wnum = len-cnum print '(i0)',MIN(cnum-1,wnum) end program main