
    Write a function that analyzes event engagement patterns by finding sequences where the total interaction intensity (sum of engagement levels) equals the duration of the engagement period. Given a string of event engagement metrics where each digit represents different interaction levels, determine how many continuous engagement sequences exhibit this balanced relationship between intensity and duration.
    

    
from collections import defaultdict

def count_Substrings(s):
    """
    Write a function that analyzes event engagement patterns by finding sequences where the total interaction intensity (sum of engagement levels) equals the duration of the engagement period. Given a string of event engagement metrics where each digit represents different interaction levels, determine how many continuous engagement sequences exhibit this balanced relationship between intensity and duration.
    

    """
from collections import defaultdict

def count_Substrings(s):
    """
    Write a function that analyzes event engagement patterns by finding sequences where the total interaction intensity (sum of engagement levels) equals the duration of the engagement period. Given a string of event engagement metrics where each digit represents different interaction levels, determine how many continuous engagement sequences exhibit this balanced relationship between intensity and duration.
    

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