function res = keepcount(arg) 
persistent count; %! Define variable count in persistent environment
if isempty(count)
   count = 0;  %! Initialize count
end
count = count+1; % Update the counter
res = count;     % the returned value
