According to the FAQ on IMDb, it was assumed that she was taught that in her training:
In some cultures, they teach you a way to tell many different things
just by looking at the lines of the palm. So, it is assumed that she
read those lines to judge the amount of time she was out. Notice the
close up shot of those lines before she says, "4 years?"
Beatrix had extensive training and education. She could have easily been taught the art of palmistry through her training. This would have allowed her to look at the lines on her palm to determine her age at the time that she woke up.
Learning how to identify the primary lines used in palmistry can help
you read hands, and may help you calculate a person's age or vitality
in life.
Beatrix learns most of her skills from Pai Mei. This could be where she would have learned the art of palmistry.