use std::io::{self, Read};
use libc::{clock_gettime, timespec, CLOCK_PROCESS_CPUTIME_ID};

fn main() {
    let mut sum = 0;
    let mut data = String::new();
    io::stdin().read_to_string(&mut data).unwrap();
    let mut begin = timespec {
        tv_sec: 0,
        tv_nsec: 0,
    };
    unsafe {
        clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &mut begin);
    };
    for line in data.lines() {
        let mut vec = Vec::new();
        let replacements = [
            ("1", 1),
            ("2", 2),
            ("3", 3),
            ("4", 4),
            ("5", 5),
            ("6", 6),
            ("7", 7),
            ("8", 8),
            ("9", 9),
            ("one", 1),
            ("two", 2),
            ("three", 3),
            ("four", 4),
            ("five", 5),
            ("six", 6),
            ("seven", 7),
            ("eight", 8),
            ("nine", 9),
        ];

        let serror = line.to_string();

        for i in 0..serror.len() {
            for &(word, num) in &replacements {
                let mut end = i + word.len();
                if end > serror.len() {
                    end = serror.len();
                }
                let fisht = &serror[i..end];
                if fisht == word {
                    vec.push(num);
                }
            }
        }

        let mut sussy = vec.first().unwrap().to_owned();
        sussy = sussy * 10 + vec.last().unwrap().to_owned();
        sum += sussy;
    }

    println!("{sum:?}");
    let mut end = timespec {
        tv_sec: 0,
        tv_nsec: 0,
    };
    unsafe {
        clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &mut end);
    };
    println!(
        "time: {:.6}ms",
        (end.tv_nsec - begin.tv_nsec) as f32 / 1000.0 / 1000.0
    );
}
