A search is presented for single top quark production in the s channel in proton-proton collisions with the CMS detector at the CERN LHC in decay modes of the top quark containing a muon or an electron in the final state. The signal is extracted through a maximum-likelihood fit to the distribution of a multivariate discriminant defined using boosted decision trees to separate the expected signal contribution from background processes. The analysis uses data collected at centre-of-mass energies of 7 and 8 TeV and corresponding to integrated luminosities of 5.1 and 19.7 fb(-1), respectively. The measured cross sections of 7.1 +/- 8.1 pb (at 7 TeV) and 13.4 +/- 7.3 pb (at 8 TeV) result in a best fit value of 2.0 +/- 0.9 for the combined ratio of the measured and expected values. The signal significance is 2.5 standard deviations, and the upper limit on the rate relative to the standard model expectation is 4.7 at 95% confidence level.