Algorithm to count DNA nucleotides