let input = require("fs").readFileSync(0, "utf8").toString().trim().split('');
let dmg_weight;
const chk_num = Number(input.splice(12)[0]);
const acc = input.reduce((acc,v,i) => {
    if(v !== '*') {
        if(i%2 === 0) return acc += Number(v);
        else return acc += 3*Number(v);
    }
    else {
        if(i%2 === 0) dmg_weight = 1;
        else dmg_weight = 3;
        return acc;
    }
},0);

for(let i=0; i<10; i++) {
    if((i*dmg_weight + acc + chk_num)%10 === 0) {
        console.log(i);
        break;
    }
}
