Several properties of the solar system, including the wide radial spacing and orbital eccentricities of giant planets, can be explained if the early solar system evolved through a dynamical instability followed by migration of planets in the planetesimal disk. Here we report the results of a statistical study, in which we performed nearly 104 numerical simulations of planetary instability starting from hundreds of different initial conditions. We found that the dynamical evolution is typically too violent, if Jupiter and Saturn start in the 3:2 resonance, leading to ejection of at least one ice giant from the solar system. Planet ejection can be avoided if the mass of the transplanetary disk of planetesimals was large (M disk >~ 50 M Earth), but we found that a massive disk would lead to excessive dynamical damping (e.g., final e 55 <~ 0.01 compared to present e 55 = 0.044, where e 55 is the amplitude of the fifth eccentric mode in the Jupiter's orbit), and to smooth migration that violates constraints from the survival of the terrestrial planets. Better results were obtained when the solar system was assumed to have five giant planets initially, and one ice giant, with mass comparable to that of Uranus and Neptune, was ejected into interstellar space by Jupiter. The best results were obtained when the ejected planet was placed into the external 3:2 or 4:3 resonance with Saturn and M disk ~= 20 M Earth. The range of possible outcomes is rather broad in this case, indicating that the present solar system is neither a typical nor expected result for a given initial state, and occurs, in best cases, with only a sime5% probability (as defined by the success criteria described in the main text). The case with six giant planets shows interesting dynamics but does offer significant advantages relative to the five-planet case.