SANTIAGO, Chile (AP) — All 33 Chilean miners trapped deep underground for 17 days were found alive Sunday, Chile's president confirmed.

A probe sent some 2,257 feet (688 meters) deep into the collapsed mine early in the morning came back with a handwritten note: "All 33 of us are fine in the shelter."

President Sebastian Pinera joined authorities and family members in congratulations and hugs. They climbed a nearby hill, planted 33 flags and sang the national anthem.

"We are overjoyed at the news," said Pinera, who euphorically waved the note written in red letters. "Today all of Chile is crying with excitement and joy."

Mine officials and relatives of the workers had hoped the men reached the shelter when a tunnel collapsed Aug. 5 at the San Jose gold and copper mine about 528 miles (850 kilometers) north of the capital, Santiago. But they had said air and food supplies were limited.

When rescuers sent the probe early Sunday, one of eight drilled since the mine collapse, they heard hammering sounds and immediately turned optimistic.

Pinera traveled to the site after contact was made with the shelter.

A miner identified as Mario Gomez sent a separate note to his wife confirming their exact underground location.

Rescuers say it could take four months to get the miners out. But they will lower water, food, oxygen and sound and video equipment through another probe in the meantime.

Rescue equipment brought from outside the country was being assembled Sunday to dig a tunnel 27 inches (68 centimeters) in diameter through which the miners will eventually be brought to the surface.

Rescuers had tried seven times before to reach the shelter, most recently drilling 2,300 feet (700 meters) and missing the target on Thursday.

They blamed the error on the company's maps of the mine.

Hundreds of workers are using equipment from the United States and Australia in the rescue.