Finding All Matches with Regular Expressions in PHP

Using the function preg_match_all you can find out the number of all matches with the regular expression:

php<?php
  $str = 'a aa aaa bbb';
  echo preg_match_all('#a+#', $str); // outputs 3
?>
Задание 1

A string is given. Find out how many numbers are in this string.