For this Question: Given a number N in the form of a string, find the number of its good substrings.
A good substring is a substring that is divisible by the given prime p. A good substring can start with a 0.The first line of input contains a single number, the length of the string, |N|
The second line of input contains the number N.
The third and final line of input contains a prime number p.

Constraints
1 <= |N| <= 100000
2 <= p <= 10000
p is a prime numberThe only line of output contains the number of good substrings.Sample Input
4
3543
3

Sample Output
6

Explanation
Good substrings are 3, 354, 3543, 54, 543, 3, I have written this Solution Code: from collections import Counter
N = int(input())
S = input().strip()
P = int(input())
if P == 2 or P == 5:
    ans=0
    for i in range(N):
        if int(S[i])%P==0:
            ans+=(i+1)
    print(ans)
    exit()
S = [int(i) for i in S][::-1]
T = [0]*(N+1)
x = 1
for i in range(N):
    T[i+1] = S[i]*x + T[i]
    T[i+1] %= P
    x *= 10
    x %= P

ans = 0
for k,v in Counter(T).items():
    ans += v*(v-1)//2
print(ans), In this Programming Language: Python, Now tell me if this Code is compilable or not?