This phrase literally describes the behavior of a person or a child counting beans. It can express a simple mathematical activity or game, and can also be used to describe a person's trivial behavior when he is bored or idle.