Let the total capacity of the bucket be C liters.
Initially, the bucket is full, so it contains C liters of water.
Amount of water removed:
\[ \frac{3}{10} \times C \]
Amount of water remaining:
\[ C - \frac{3}{10}C = \frac{7}{10}C \]
Total water in the bucket now:
\[ \frac{7}{10}C + 4 \]
Amount of water removed:
\[ \frac{1}{5} \times \left( \frac{7}{10}C + 4 \right) \]
Amount of water remaining:
\[ \frac{7}{10}C + 4 - \frac{1}{5} \times \left( \frac{7}{10}C + 4 \right) \]
We are given that the remaining water is \( \frac{2}{3}C \). Therefore:
\[ \frac{7}{10}C + 4 - \frac{1}{5} \times \left( \frac{7}{10}C + 4 \right) = \frac{2}{3}C \]
Multiply both sides by 15 to eliminate fractions:
\[ 4 \times \left( \frac{7}{10}C + 4 \right) = 10 \times \frac{2}{3}C \] \[ 4 \times \frac{7}{10}C + 4 \times 4 = \frac{20}{3}C \] \[ C = 30 \]
The capacity of the bucket is 30 liters.