I'd spend three days in the Lençóis Maranhenses, based in Barreirinhas: two for the lagoon circuits and one for the Preguiças river. On the first, arrive from São Luís, on a road of about 4 hours, and do the Lagoa Azul Circuit in the afternoon, with sunset on the dunes. On the second, take the speedboat trip along the Preguiças, with Vassouras, the Mandacaru lighthouse and lunch in Caburé, returning in mid-afternoon. On the third, leave the morning free in town and keep the afternoon for the Lagoa Bonita Circuit. That's three nights in Barreirinhas, returning to São Luís on the morning of the fourth day. With a fourth day, and the return on the fifth, I'd go to Atins on the full-day 4x4 circuit, to see the mouth of the Preguiças and the beach where the dunes meet the sea. With two days, there's room for the Lagoa Azul Circuit on arrival and just one more trip, Lagoa Bonita or the river, and the road there and back eats up much of the time. If you have more days and travel between June and August, you can add Santo Amaro do Maranhão as a second base, or do the crossing on foot from Atins to Santo Amaro, three to five days, booked well in advance.