If TEXTJOIN function is available to you then you can try below formula as well.
In cell AC2:
=LEN(TRIM(MID(SUBSTITUTE(" "&TRIM(TEXTJOIN("",TRUE,IF($C2:$AA2<>"",1," ")))," ",REPT(" ",99)),99*COLUMNS($A$1:A$1),99)))
Copy down and across.
In cell AP2:
=LEN(TRIM(MID(SUBSTITUTE("...