"use strict";
    
const main = arg => {
    arg = arg.split("\n");
    const times = arg.map(n=>parseInt(n));
    let timer   = 0;
    let min = 10;
    
    let sum = 0;
    
    for(let i in times) {
        let digitOne   = parseInt(String(times[i]).split("").pop());
        let digitMinus = 10 - digitOne;
        sum += parseInt(times[i]);
        
        if(digitMinus !== 10) {
            sum += digitMinus;
        }
        
        if(digitMinus !== 10 && digitOne < min) {
            min = digitOne;
        }
    }

    console.log(sum - (10 - min));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));