
    In a delivery route optimization system, analyze route segment codes to find valid sub-segments where the sum of the stop counts equals the length of that sub-segment code. Given a route code string where each digit represents the number of stops in that segment, determine how many sub-segments satisfy this efficiency criteria.
    

    
from collections import defaultdict

def count_Substrings(s):
    """
    In a delivery route optimization system, analyze route segment codes to find valid sub-segments where the sum of the stop counts equals the length of that sub-segment code. Given a route code string where each digit represents the number of stops in that segment, determine how many sub-segments satisfy this efficiency criteria.
    

    """
from collections import defaultdict

def count_Substrings(s):
    """
    In a delivery route optimization system, analyze route segment codes to find valid sub-segments where the sum of the stop counts equals the length of that sub-segment code. Given a route code string where each digit represents the number of stops in that segment, determine how many sub-segments satisfy this efficiency criteria.
    

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