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

# Test cases
assert count_Substring_With_Equal_Ends("abc") == 3
assert count_Substring_With_Equal_Ends("abcda") == 6
assert count_Substring_With_Equal_Ends("ab") == 2
```