import Data.Char
import Data.List

pack [] = []
pack (s:sr) =
  let n = length $ takeWhile (== s) sr
      r = dropWhile (== s) sr
  in
    (s,n+1):(pack r)

cnt = (pack . sort)

take' _ [] = []
take' a ((b,n):xs) =
  if ord(b) - ord(a) == 1
  then (b,n):(take' b xs)
  else []

dec 0 x = x
dec l [] = error $ show l
dec l x@((a,1):xs) = dec (l-1) xs
dec l x@((a,n):xs) = (a,n-1):(dec (l-1) xs)

cmp [] = 0
cmp i@((a,n):xs) =
  let p = (a,n):(take' a xs)
      l = length p
      d = dec l i
  in
    if l >= 4
    then (l-3) + cmp d
    else cmp d
  
ans i =
  let l = length i
      a = filter(\x -> ord(x) >= ord('a') && ord(x) <= ord('z')) i
      n = filter(\x -> ord(x) >= ord('0') && ord(x) <= ord('9')) i
      ca= cmp $ cnt a
      cn= cmp $ cnt n
  in
    l - ca - cn

main = do
  c <- getContents
  let i = lines c
      o = map ans i
  mapM_ print o