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

# Example usage:
print(count_palindromic_substrings("abc"))  # Output: 3
print(count_palindromic_substrings("aaa"))  # Output: 6
```