I will solve the problem by 2 methods.
Method 1 to solve:
I will use Gauss's formula for calculating each string, then we will decrease the results.
We find the number of terms of each string.

Method 2 to solve:
We intersect the terms in the second string among the terms of the first string.
