count_a and count_b to 0, representing the counts of pattern[0] and pattern[1] respectively.total_subsequences to 0.c in text:
a. If c is equal to pattern[1], increment total_subsequences by count_a and increment count_b.
b. If c is equal to pattern[0], increment count_a.total_subsequences plus the maximum of count_a and count_b.