Under construction

Still being built. Things may change

Exam at British Intelligence

Time limit2sMemory limit1024 MB

Summary
Given a string s, find every k such that s splits into k equal-length pieces that are all cyclic shifts of each other.
Level

Medium6 of 10

Topics
String matching, String, Math
Solved
No attempts yet

Problem

Finn Maxmisl is an agent of British Intelligence. Every agent must be ready for unexpected situations and must be able to solve any assigned task within seconds. Besides physical standards, the final exam at the intelligence academy also requires solving complex algorithmic tasks. Finn received the following one.

A string ss of length nn is given. Call it kk-splittable if it can be split into kk contiguous substrings of equal length so that every substring can be obtained from any other one by a cyclic shift.

A string ss is a cyclic shift of a string tt if there exist strings uu and vv (either may be empty) such that t=uvt = uv and s=vus = vu.

Find all kk for which the string ss is kk-splittable.

Since every method is fair game in intelligence work, Finn asked you for help.

Input

The first line contains the string ss (1≤∣s∣≤200 0001 \le |s| \le 200\,000), consisting of lowercase Latin letters.

Output

The first line prints the number mm of suitable values of kk.

The second line prints the mm suitable values kik_i in increasing order, separated by spaces.

Hint

In the first sample, the string can stay as it is and be split into two strings abba and baab, which are cyclic shifts of each other. It can also be split into four strings ab, ba, ba, and ab, which are cyclic shifts of each other.

Examples2

  1. Example 1

    Input
    abbabaab
    
    Expected output
    3
    1 2 4
    
  2. Example 2

    Input
    abbababa
    
    Expected output
    2
    1 4