//  #牛客春招刷题训练营# https://www.nowcoder.com/discuss/726480854079250432
#include <iostream>
using namespace std;

int main() {
  ios_base::sync_with_stdio(false),cin.tie(0);
  int n, m;
  cin >> n >> m;
  int ans = 0, x;
  for(int i = 0; i < n * m; i++){//---------输入
    cin >> x;
    if (x % 10 == 9) ans++;//-----------取余-》保留个位-》判断
  }
  cout << ans;
}
// 64 位输出请用 printf("%lld")