const n = require("fs").readFileSync(0, "utf8").toString().split("\n").map(Number);
let arr = Array.from({length:42}, (_,i) => i);
let flag = 1, cnt=0;
for(let i=0; i<10; i++){
    if(n[i]%42==0) flag = 0;
    arr[n[i]%42]=0;
}
for(let i=flag; i<42; i++){
    if(arr[i]==0) cnt++;
}
console.log(cnt);