After clicking the "Complete Sign-up" button, Max is prompted that his
Note that passwords can only be lowercase letters.
Max thought
Why do some websites have maximum length requirements for passwords?
Then, he set this problem in anger.
Max found the hash function that this website uses for passwords in C++, Java, and Python:
C++:
int get_hash(string s) {
int hash = 0;
for (int i = 0; i < (int)s.size(); i++) {
hash = hash * 13 + s[i] - 'a' + 1;
}
return hash;
}
Java:
static int get_hash(String s) {
int hash = 0;
for (int i = 0; i < s.length(); i++) {
hash = hash * 13 + s.charAt(i) - 'a' + 1;
}
return hash;
}
Python:
def get_hash(s):
hash = 0
for i in range(len(s)):
hash = hash * 13 + ord(s[i]) - ord('a') + 1
return hash
Max figured that if he could count the number of passwords with a length of
Can you help Max count the number of passwords to convince the website to change this policy?
Constraints
Note that passwords can only be lowercase letters.
Input Specification
The first line will contain two integers,
Output Specification
Output the number of passwords with a length of
Sample Input 1
1
16
Sample Output 1
1
Sample Input 2
4
32130
Sample Output 2
8
Comments