Count number of characters in a cell excluding spaces

Cell Reference:
enter the cell from which you want to count the number of characters
Formula:

=LEN(SUBSTITUTE(B5," ",""))
=LEN(SUBSTITUTE(B5," ",""))