Multilayer relaxations at the (0001) surface of Be and Mg