
    Design a function to identify viable mini-route segments in a bus route's passenger data string, where a viable segment is defined as a continuous sequence of stops whose total passenger count equals the number of stops in that sequence. Given an encoded string where each digit represents the number of passengers at sequential bus stops, determine how many such viable mini-route segments exist within the complete route.
    

    
from collections import defaultdict

def count_Substrings(s):
    """
    Design a function to identify viable mini-route segments in a bus route's passenger data string, where a viable segment is defined as a continuous sequence of stops whose total passenger count equals the number of stops in that sequence. Given an encoded string where each digit represents the number of passengers at sequential bus stops, determine how many such viable mini-route segments exist within the complete route.
    

    """
from collections import defaultdict

def count_Substrings(s):
    """
    Design a function to identify viable mini-route segments in a bus route's passenger data string, where a viable segment is defined as a continuous sequence of stops whose total passenger count equals the number of stops in that sequence. Given an encoded string where each digit represents the number of passengers at sequential bus stops, determine how many such viable mini-route segments exist within the complete route.
    

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