A sequence $a_n$ of real numbers satisfies the following conditions:

- $a_1 = 1$
- $a_2 = 0$
- $a_n = (S_{n-1} + 1) S_{n-2}$ for all integers $n \geq 3$

where $S_k = a_1 + a_2 + \dots + a_k$ for positive integers $k$. 

Determine the smallest integer $m > 2$ such that $127$ divides $a_m$.

Let's think step by step and output the final answer within \boxed{}.
user