Count files matching pattern

COUNT=0;

while read filename; do
  COUNT=$((COUNT + 1));
done <<< "$(find . -iname 'IMG_??????_??????.jpg')";

echo "Number of files found: $COUNT"
COUNT=0;

while read -rd $'' filename; do
  COUNT=$((COUNT + 1));
done < <(find . -iname 'IMG_??????_??????.jpg' -print0);

echo "Number of files found: $COUNT"
COUNT=0

find . -iname 'IMG_??????_??????.jpg' -print0 |
  while read -rd $'' filename do
    (($COUNT++))
  done

echo "Number of files found: $COUNT"