I don’t see how the second parts of your code fit into the first.
To get the count of rows it is either
$count = count(get_field('repeater_field_name'));
OR
$count = count(get_field('repeater_field_name'));
depending, of course if it is a sub field.
In any case you must get the count of rows before calling have_rows() for the repeater you want the count of.