Sergei chooses two different natural numbers $a$ and $b$. He writes four numbers in a notebook: $a$, $a+2$, $b$ and $b+2$. He then writes all six pairwise products of the numbers of notebook on the blackboard. Let $S$ be the number of perfect squares on the blackboard. Find the maximum value of $S$.

[i]S. Berlov[/i]
To solve the problem, we need to analyze the pairwise products of the numbers \(a\), \(a+2\), \(b\), and \(b+2\) and determine how many of these products can be perfect squares. 

1. **List the pairwise products:**
   The six pairwise products are:
   \[
   a(a+2), \quad a \cdot b, \quad a(b+2), \quad (a+2)b, \quad (a+2)(b+2), \quad b(b+2)
   \]

2. **Analyze each product:**
   - \(a(a+2)\)
   - \(a \cdot b\)
   - \(a(b+2)\)
   - \((a+2)b\)
   - \((a+2)(b+2)\)
   - \(b(b+2)\)

3. **Determine conditions for perfect squares:**
   For each product to be a perfect square, the following must hold:
   - \(a(a+2) = k^2\) for some integer \(k\)
   - \(a \cdot b = m^2\) for some integer \(m\)
   - \(a(b+2) = n^2\) for some integer \(n\)
   - \((a+2)b = p^2\) for some integer \(p\)
   - \((a+2)(b+2) = q^2\) for some integer \(q\)
   - \(b(b+2) = r^2\) for some integer \(r\)

4. **Check specific cases:**
   Let's consider specific values of \(a\) and \(b\) to maximize the number of perfect squares.

   - If \(a = 0\) and \(b = 0\), then \(a\) and \(b\) are not different natural numbers.
   - If \(a = 1\) and \(b = 1\), then \(a\) and \(b\) are not different natural numbers.
   - If \(a = 1\) and \(b = 2\), then:
     \[
     a(a+2) = 1 \cdot 3 = 3 \quad (\text{not a perfect square})
     \]
     \[
     a \cdot b = 1 \cdot 2 = 2 \quad (\text{not a perfect square})
     \]
     \[
     a(b+2) = 1 \cdot 4 = 4 \quad (\text{a perfect square})
     \]
     \[
     (a+2)b = 3 \cdot 2 = 6 \quad (\text{not a perfect square})
     \]
     \[
     (a+2)(b+2) = 3 \cdot 4 = 12 \quad (\text{not a perfect square})
     \]
     \[
     b(b+2) = 2 \cdot 4 = 8 \quad (\text{not a perfect square})
     \]

   - If \(a = 2\) and \(b = 3\), then:
     \[
     a(a+2) = 2 \cdot 4 = 8 \quad (\text{not a perfect square})
     \]
     \[
     a \cdot b = 2 \cdot 3 = 6 \quad (\text{not a perfect square})
     \]
     \[
     a(b+2) = 2 \cdot 5 = 10 \quad (\text{not a perfect square})
     \]
     \[
     (a+2)b = 4 \cdot 3 = 12 \quad (\text{not a perfect square})
     \]
     \[
     (a+2)(b+2) = 4 \cdot 5 = 20 \quad (\text{not a perfect square})
     \]
     \[
     b(b+2) = 3 \cdot 5 = 15 \quad (\text{not a perfect square})
     \]

5. **Generalize the solution:**
   After checking several cases, it appears that it is difficult to find more than one perfect square among the products. Therefore, we need to consider if there is a theoretical maximum.

6. **Conclusion:**
   Based on the analysis, the maximum value of \(S\) is 1, as it is challenging to find more than one perfect square among the products.

The final answer is \(\boxed{1}\)