Setsubun (節分) is the day before the beginning of spring in Japan. The name literally means 'seasonal division', but usually the term refers to the spring Setsubun, properly called Risshun (立春) celebrated yearly on February 3 as part of the Spring Festival (春祭, haru matsuri). In its association with the Lunar New Year, spring Setsubun can be and was previously thought of as a sort of New Year's Eve, and so was accompanied by a special ritual to cleanse away all the evil of the former year and drive away disease-bringing evil spirits for the year to come. This special ritual is called mamemaki (豆撒き, "bean scattering"). Setsubun has its origins in tsuina (追儺), a Chinese custom introduced to Japan in the eighth century.
The custom of mamemaki first appeared in the Muromachi period. It is usually performed by the toshiotoko (年男) of the household (the male who was born on the corresponding animal year on the Chinese zodiac), or else the male head of the household. Roasted soybeans (called "fortune beans" (福豆, fuku mame)) are thrown either out the door or at a member of the family wearing an Oni (demon or ogre) mask, while the people say "Demons out! Luck in!" (鬼は外! 福は内!, Oni wa soto! Fuku wa uchi!) and slam the door. This is still common practice in households but many people will attend a shrine or temple's spring festival where this is done. The beans are thought to symbolically purify the home by driving away the evil spirits that bring misfortune and bad health with them. Then, as part of bringing luck in, it is customary to eat roasted soybeans, one for each year of one's life, and in some areas, one for each year of one's life plus one more for bringing good luck for the year to come.
The gestures of mamemaki look similar to the Western custom of throwing rice at newly married couples after a wedding.