
    Design a function to analyze a student's performance sequence, where each digit represents a module score, and find all learning segments where the sum of scores equals the number of modules in that segment. This analysis helps identify balanced learning progressions where the total achievement level matches the length of the study period.
    

    
from collections import defaultdict

def count_Substrings(s):
    """
    Design a function to analyze a student's performance sequence, where each digit represents a module score, and find all learning segments where the sum of scores equals the number of modules in that segment. This analysis helps identify balanced learning progressions where the total achievement level matches the length of the study period.
    

    """
from collections import defaultdict

def count_Substrings(s):
    """
    Design a function to analyze a student's performance sequence, where each digit represents a module score, and find all learning segments where the sum of scores equals the number of modules in that segment. This analysis helps identify balanced learning progressions where the total achievement level matches the length of the study period.
    

    """
    n = len(s)
    (count, sum) = (0, 0)
    mp = defaultdict(lambda : 0)
    mp[0] += 1
    for i in range(n):
        sum += ord(s[i]) - ord('0')
        count += mp[sum - (i + 1)]
        mp[sum - (i + 1)] += 1
    return count