counting the layers instead of inputing the number