Words

Time limit: 0.2s Memory limit: 64MB Input: Output:

William loves words and likes to collect them in special dictionaries. Today, he's building a dictionary that contains all the words. Or actually: all the words that can be formed with the 2626 English letters.

The size of this dictionary is, naturally, infinite. This means that it wouldn't be practical to generate the dictionary to, say, a text file on disk, since it would require an infinite amount of space. However, William would still like to be able to identify the location in the dictionary of a given word.

The ordering rule in this special dictionary is a bit unusual: we consider shorter words to always come before longer ones. For example, the word xy comes before abc, simply because it is shorter. If two words have the same length, they are ordered in the traditional (lexicographic) way, so xyz > abc.

This means that the first 2626 words in the dictionary are formed by only one character: a,b,,za, b, \dots, z. The next words are formed by only two characters, and so on.

Help William by writing a program that, given a word, calculates its zero-based index in the dictionary. That is: a=0a = 0, b=1b = 1, and so on. Since this value can be really big, we need its value modulo 109+710^9 + 7.

Input data

The input contains the word WW, a string consisting of lowercase English letters.

Output data

The output will contain the zero-based index in the dictionary modulo 109+710^9 + 7.

Constraints and clarifications

  • 1W1051 \leq |W| \leq 10^5
  • For tests worth 2020 points, 1W31 \leq |W| \leq 3.
  • For tests worth 2020 more points, WW has only a in it.
  • For tests worth 4040 more points, 1W1031 \leq |W| \leq 10^3.

Example 1

stdin

abba

stdout

18980

Example 2

stdin

verylongstring

stdout

315607945

Log in or sign up to be able to send submissions!