This works, but it might be slightly better style to use "-1" here to indicate failure, since "0" is technically a valid count.