shorter solution using set size