detect the number of max custom variables