Albert and Infinite String

Albert loves playing with strings,he thought of creating an infinite string ‘s’ of lowercase English letters,but then his friend ‘a’ comes over and ask him to count number of times his name is getting repeated,just to make the life easier for Albert he asked him for only counting till the first ‘n’ character ,write a program to help Albert for the same.

Example:

S=”abcac”

N=10

The substring we consider is ‘abcacabcac”,the first 10 characters of infinite string . There are 4 occurences of a in substring.

Function description

Complete the repeatedString function in editor below

repeatedString has following parameters

s:string to repeat

n:the number of characters to consider

Returns int:the frequency of a in the substring

Input format:

The first line contains a single string s.

The second line contains an integer n.

Constraints:

-1<=|s|<=100

-1<=n<=10^12

Sample Input

Sample input 0-

Aba

10

Sample output 0-

7

Explanation 0:

The first n=10 letters of the infinite string are abaabaabaa.Because there are 7 a’s ,we return 7.

Code: