Anyone with the energy to climb out of bed before dawn and go beachcombing deserves the odd bit of luck-and in Brazil these last few days it has been very odd indeed.

Police are struggling to stop beachcombers from grabbing any of the 22 tons of marijuana washing up in 14,000 cans along 300 miles of beautiful tropical beaches.

The marijuana is packed in large, industrially sealed, unmarked containers about as large as family-size juice cans.

''This is absolutely unheard of in the annals of Brazilian contraband,''

said federal drug squad agent Claudio Barrouin.

Police suspect the illegal drugs were thrown overboard from a Panamanian- registered yacht bound for the United States from Australia, he said. The yacht entered Brazilian waters with engine problems.

Barrouin said the U.S. Drug Enforcement Agency tipped off Brazilian police about the marijuana more than a month ago. ''We were monitoring (radio) conversations between the crew and other people in Panama, where the boat was due to go before entering U.S. waters,'' he said.

The Brazilian navy sent out a frigate and a mine sweeper to find the yacht, but when they pinned her down near Rio de Janeiro they found the hold bare-and freshly scrubbed, police said.

Now police face two headaches. They have to question crew members and establish a link between the yacht and the cans before they can press trafficking charges, and they must reach the cans before Brazil`s large dope- smoking population does.

By Saturday, 2,000 cans containing about 3 tons of drugs had been found at a dozen different beaches along the coast to Rio.

Police patrols have started as early as 3:30 a.m. to try to prevent the cans from falling into what a newspaper called ''the hands of

. . . interested parties.''