Why does a flamingo lift up one leg ?

Why does a flamingo lift up one leg ? Because if he lifted up both legs it would fall over !