Please solve the programming task below using a self-contained code snippet in a markdown code block.

Given two positive integers a and b, return the number of common factors of a and b.
An integer x is a common factor of a and b if x divides both a and b.
 
Please complete the following python code precisely:
```python
class Solution:
    def commonFactors(self, a: int, b: int) -> int:
```