Four times in a student's life time. If you parent's claimed it, on your schooling, while you were their dependent, those time would count against your four.
[EDIT] The AOC cannot be used for grad school, even if you (and your parents) used it less than 4 times while you were an undergrad.
Actually both rules apply. You can only claim it for 4 years, and you can only claim it for your undergraduate degree (first 4 years of college or its equivalent.) So for example, if you are a new US resident taking a graduate program, you can't claim the AOTC because you are past your first 4 years (undergraduate equivalent) even though you never claimed it before. Or, if you are taking 5 or 6 years to get your first degree, you can only claim it for 4 years.