const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;
void (async function () {
// Write your code here
while ((line = await readline())) {
if (!global.n) {
const [n, m] = line.split(" ").map(Number);
global.n = n;
global.m = m;
global.matrix = [];
} else {
const row = line.split(" ").map(Number);
global.matrix.push(row);
if (global.matrix.length === global.n) {
const count = countDigistEndingWithNine();
console.log(count);
}
}
function countDigistEndingWithNine() {
let count = 0;
for (let i = 0; i < global.n; i++) {
for (let j = 0; j < global.m; j++) {
if (global.matrix[i][j] % 10 === 9) count++;
}
}
return count;
}
}
})();