If U is open in R, then $f^{-1}(U)$ is open, hence Borel, in S. Now suppose that $V_n\ (n=1,2,3,\ldots)$ are sets in R such that $f^{-1}(V_n)$ is Borel for each n. Then $f^{-1}\Bigl(\bigcup_nV_n\Bigr) = \bigcup_nf^{-1}(V_n)$, which is a countable union of Borel sets and in therefore Borel in S. By a similar argument, $f^{-1}\Bigl(\bigcap_nV_n\Bigr)$ is Borel.
That shows that the class of subsets V ⊆ R for which $f^{-1}(V)$ is Borel in S is a σ-algebra containing all the open sets in R. Therefore this class contains all the Borel sets in R. Thus f is Borel measurable.