Count subsequences

Company: Google_5july

Difficulty: medium