calculating the bacon number