When did humans first learn to count?

The history of math is murky, predating any written records. When did humans first grasp the basic concept of a number? What about size and magnitude, or form and shape?