  We investigate analytically a long Josephson 0-$\pi$-junction with several 0
and $\pi$ facets which are comparable to the Josephson penetration length
$\lambda_J$. Such junctions can be fabricated exploiting (a) the d-wave order
parameter symmetry of cuprate superconductors; (b) the spacial oscillations of
the order parameter in superconductor-insulator-ferromagnet-superconductor
structures with different thicknesses of ferromagnetic layer to produce 0 or
$\pi$ coupling or (c) the structure of the corresponding sine-Gordon equations
and substituting the phase $\pi$-discontinuities by the artificial current
injectors. We investigate analytically the possible ground states in such a
system and show that there is a critical facet length $a_c$, which separates
the states with half-integer flux quanta (semifluxons) from the trivial ``flat
phase state'' without magnetic flux. We analyze different branches of the
bifurcation diagram, derive a system of transcendental equations which can be
effectively solved to find the crossover distance $a_c$ (bifurcation point) and
present the solutions for different number of facets and the edge facets
length. We show that the edge facets may drastically affect the state of the
system.
