function! s:output() let this = {'lines': []} function! this.append(line) abort call add(self.lines, a:line) endfunction function! this.build() abort return join(self.lines, "\n") endfunction return this endfunction function! s:main(input) abort let o = s:output() let [c_t, c_r, c_e] = [0, 0, 0] let l = len(a:input[0]) let i = 0 while i < l let c = a:input[0][i] if c ==# 't' let c_t += 1 elseif c ==# 'r' let c_r += 1 elseif c ==# 'e' let c_e += 1 endif let i += 1 endwhile let c_e = c_e / 2 let r = min([c_t, c_r, c_e]) call o.append(r) return o.build() endfunction let s:input = getline(1, '$') enew put =s:main(s:input) 2,$print