Counters in Turing machines
Well, you could just implement a counter.  I'll assume that the tape alphabet is $\{0,1,\#\}$.

First, scan to the end of the input, and write $\#0$ to the tape after the last character. The string of zeroes and ones after the $\#$ will be a binary counter. 

Second, convince yourself that a Turing machine can add one to a number in binary.

Third, peform the following until you run out of input.  Scan back to the first&nbsp;$1$ on the tape, replace it with a&nbsp;$\#$, scan back to the counter and add one to it.

Finally, when you've run out of input, check that the value of the counter is a number of the required type. For example, it has the value&nbsp;$2^k$ for some&nbsp;$k$ precisely if it matches the regular expression $10^*$. For $3^k$, you can either convince yourself that Turing machines can divide a binary number by&nbsp;$3$ or&nbsp;&ndash; easier!&nbsp;&ndash; keep your counter in ternary instead of binary.