
    Design a function for an automated grading system that evaluates a student's understanding of number patterns by counting how many segments within their numerical answer have a mathematical property where the sum of the digits equals the segment's length. This assessment helps identify if students can recognize relationships between digit sums and string lengths, providing insights into their pattern recognition abilities.
    

    
from collections import defaultdict

def count_Substrings(s):
    """
    Design a function for an automated grading system that evaluates a student's understanding of number patterns by counting how many segments within their numerical answer have a mathematical property where the sum of the digits equals the segment's length. This assessment helps identify if students can recognize relationships between digit sums and string lengths, providing insights into their pattern recognition abilities.
    

    """
from collections import defaultdict

def count_Substrings(s):
    """
    Design a function for an automated grading system that evaluates a student's understanding of number patterns by counting how many segments within their numerical answer have a mathematical property where the sum of the digits equals the segment's length. This assessment helps identify if students can recognize relationships between digit sums and string lengths, providing insights into their pattern recognition abilities.
    

    """
    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