Calculate needed size