You are given a string, str, as a binary representation of an integer. Your task is to return the number of steps needed to reduce it to 1 by following these rules:
If the number is even, divide it by 2.
If the number is odd, add 1 to it.
You can always reach 1 for all provided test cases.
Constraints: