$/=!<>;$w+=3-2*($a[$_]^=1)for<>=~/\d+/g;print$w>>2