One day, a man is standing by a river thinking of ways to make money fast. The devil appears in front of him and offers him a deal: every time he crosses the bridge, the money in his pocket doubles. But after the money is doubled, the man must pay a charge of $24. One cross means from one side of the river to the other, not back and forth. The man crosses 3 times. After the 3rd time of paying the charge, the man looks in his pocket to find $0. How much did he have in the beginning?