Prefix-Suffixes

No attempts yetTime limit1sMemory limit128 MB

Problem

A prefix-suffix (a border) of a word ww is a word vv that is both a prefix (an initial fragment) and a suffix (a final fragment) of ww. A proper prefix-suffix of ww is any prefix-suffix that is non-empty and strictly shorter than ww. Let PS(w)\mathrm{PS}(w) denote the number of proper prefix-suffixes of ww. Let w[i,j]w[i, j] denote the substring of ww that starts at position ii and ends at position jj; positions are numbered from 11.

Given a word ww, compute the total number of proper prefix-suffixes over all substrings of ww, that is

1ijwPS(w[i,j])\sum_{1 \le i \le j \le |w|} \mathrm{PS}(w[i, j])

Input

The first and only line of input contains the word ww. Its length satisfies 1w1051 \le |w| \le 10^5, and it consists only of lowercase English letters.

Output

Print a single integer: the total number of proper prefix-suffixes over all substrings of ww.