A newborn flamingo is ash grey. The pink doesn't come built in: it eats its way to it.
Its diet — tiny crustaceans and algae loaded with carotenoids, the same pigments that colour carrots — gradually deposits colour in its feathers, its legs and even its beak. A very pink flamingo is, literally, a very well-fed flamingo; that's why the shade works as a sign of health when choosing a mate.
Zoos had to learn this the hard way: the first captive flamingos faded to white, and today their food is supplemented with pigment so they don't lose their colour.
Source: Smithsonian National Zoo