  We propose a subvolume method to study the $\theta$ dependence of the free
energy density of the four-dimensional SU($N$) Yang-Mills theory on the
lattice. As an attempt, the method is first applied to SU(2) Yang-Mills theory
at $T=1.2\,T_c$ to understand the systematics of the method. We then proceed to
the calculation of the vacuum energy density and obtain the $\theta$ dependence
qualitatively different from the high temperature case. The numerical results
combined with the theoretical requirements provide the evidence for the
spontaneous CP violation at $\theta = \pi$, which is in accordance with the
large $N$ prediction and indicates that the similarity between 4d SU($N$) and
2d CP$^{N-1}$ theories does not hold for $N$=2.
