include "primitives.alh"

Integer function b2d(param : String):
	Integer value
	value = 0
	Integer length
	length = string_len(param)
	Integer counter
	counter = integer_subtraction(length, 1)
	Integer accumul
	accumul = 1

	while (counter >= 0):
		if (string_get(param, counter) == "1"):
			value = integer_addition(value, accumul)
		accumul = integer_multiplication(accumul, 2)
		counter = integer_subtraction(counter, 1)

	return value

Void function main():
	while(True):
		output(b2d(input()))
