```python
def count_Substrings(s, n):
    """
    Counts the number of substrings where the sum of digits equals the length.

    The condition `sum(digits) == length` for a substring can be rewritten as
    `sum(digits) - length == 0`. This is equivalent to `sum(digit - 1) == 0`
    for each digit in the substring.

    This transforms the problem into finding the number of subarrays in a
    transformed sequence (where each element is `digit - 1`) that sum to zero.
    This can be solved efficiently in O(n) time using a hash map to track
    the frequencies of prefix sums.

    Args:
        s: A string of digits.
        n: The length of the string s.

    Returns:
        The count of such substrings.
    """
    count = 0
    current_prefix_sum = 0
    
    # A dictionary to store the frequency of each prefix sum encountered.
    # We initialize it with {0: 1} to handle subarrays that start from index 0.
    prefix_sum_counts = {0: 1}

    for char in s:
        # Update the prefix sum with the transformed value (digit - 1).
        current_prefix_sum += int(char) - 1

        # If a prefix sum `P` has been seen `k` times before, and we see it
        # again, it means there are `k` new subarrays ending at the current
        # position whose transformed values sum to zero.
        count += prefix_sum_counts.get(current_prefix_sum, 0)

        # Increment the frequency of the current prefix sum.
        prefix_sum_counts[current_prefix_sum] = prefix_sum_counts.get(current_prefix_sum, 0) + 1

    return count
```