function [num] = digit_counter(filename)
fid = fopen(filename, 'r');
if fid < 0
error('error opening file%s\n', filename)
end
n = fread(fid,1, 'double');
dims = fread(fid,n, 'double');
A = fread(fid, 'double');
A = reshape(A, dims);
[m, n] = size(A);
counter = 0 ;
for j = 1 : n
for i = 1 : m
if A(i,j) == 0 || A(i,j) == 1 ||A(i,j) == 2 || A(i,j) == 3 || A(i,j) == 4 || A(i,j) == 5 || A(i,j) == 6 || A(i,j) == 7 || A(i,j) == 8 || A(i,j) == 9
counter = counter + 1 ;
end
end
end
num = counter ;
fclose(fid) ;
end