Measure your head and subtract a couple of inches because hats are stretchy so if you make one the same size, it'll be too large. Then you have to figure out your sts per inch with the yarn and needles you want to use and multiply it times the finished measurement. Here's a basic
hat recipe that will walk you through the 'formula' you need.