You can do this in the most direct way - transform every digit to a binary number in a fixed number of bits.
This way you can go over the formula (once) and count the number of variables and number of clauses.

And there is no need to post the same question twice in the same day - we cannot be here 24/7.