let () =
  let is_nonzero = function
      1|2|3|4|5|6|7|8|9 -> true
      | _ -> false in
  let is_digit = function
      0 -> true
    | i when is_nonzero i -> true
    | _ -> false in
  let get_num s =
    let maxlen = String.length s in
    let rec loop idx len n = function
        i when i = maxlen -> if len <> 0 then (int_of_string (String.sub s idx len))::n else n
      | i ->
         let c = Char.code(s.[i])-48 in
         if len = 0 then
           if is_nonzero(c) then
             loop i 1 n (i+1)
           else
             loop idx len n (i+1)
         else
           if is_digit(c) then
             loop idx (len+1) n (i+1)
           else
             loop 0 0 ((int_of_string (String.sub s idx len))::n) (i+1)
    in loop 0 0 [] 0
  in
  let rec read sum =
    try let line = read_line () in
        let n = get_num line in
        if List.length n > 0 then
          read (sum + (List.fold_left (+) 0 n))
        else
          read sum
    with End_of_file ->
      Printf.printf "%d\n" sum
  in read 0
;;