Abstract. We present an algorithm for counting the irreducible components of a complex algebraic variety defined by a fixed number of polynomials encoded as straight-line programs (slps). It runs in polynomial time in the Blum-Shub-Smale (BSS) model and in randomized parallel polylogarithmic time in the Turing model, both measured in the lengths and degrees of the slps. Our algorithm is obtained from an explicit version of Bertini's theorem. For its analysis we further develop a general complexity theoretic framework appropriate for algorithms in algebraic geometry. Keywords. algebraic varieties, complexity, irreducible components, Bertini's theorem Subject classification. 14Q15, 68Q15, 68Q25, 68W30, 68W40