Counting the number of unique substrings
Swift
Medium
strings
Task «Counting the number of unique substrings»
Given a string S consisting of lowercase Latin letters. It is necessary to count the number of distinct substrings in this string. Substrings are considered distinct if they differ by at least one character. The order of characters in a substring must correspond to the order in the original string.
Input Format
The input is a single string S (1 ≤ |S| ≤ 1000), consisting of lowercase Latin letters.
Output Format
Output a single integer — the number of distinct substrings in the string S.
Examples
Example 1
INPUT
abc
OUTPUT
6
Example 2
INPUT
aaa
OUTPUT
3
main.swift