We have a string **S** and we want to calculate the number of distinct strings that can be formed by rotating the string.

For example :-

**S = "aaaa"** , here it would be 1 string {**"aaaa"**}

**S = "abab"** , here it would be 2 strings {**"abab"** , **"baba"**}

So ,is there an algorithm to solve this in O(|S|) complexity where |S| is the length of string.