------
## 最终结论
```python
def count_Substring_With_Equal_Ends(s):
    count = 0
    n = len(s)
    for i in range(n):
        for j in range(i, n):
            substring = s[i:j+1]
            if substring[0] == substring[-1]:
                count += 1
    return count

# Test cases
assert count_Substring_With_Equal_Ends('aba') == 4
assert count_Substring_With_Equal_Ends('abcab') == 7
assert count_Substring_With_Equal_Ends('abc') == 3
```