A man bought some eggs of which 10% are rotten. He gives 80% of the remainder to his neighbors. Now he is left out with 36 eggs. How many eggs he bought?