The rule is simple: use “fewer” for items that can be counted, like beans, and “less” for things that can’t—bacon, say.
There are subtle exceptions, of course—droves of them—but all we can do is try, knowing that fewer mistakes will translate into less angst among the sticklers.