Repeated String

1

1 votes
Easy
Problem

Lilah has a string, s, of lowercase English letters that she repeated infinitely many times.

Given an integer, n, find and print the number of letter a's in the first n letters of Lilah's 
infinite string.

For example, if the string s='abcac' and n=10, the substring we consider is 'abcacabcac', the 
first 10 characters of her infinite string. There are 4 occurrences of 'a' in the substring.

Input Format:

The first line contains a single string, s. 
The second line contains an integer, n.

Constraints
1. 1<=|s|<=100
2. 1<=n<=10^12

Output Format

Print a single integer denoting the number of letter a's in the first n letters of the infinite 
string created by repeating s infinitely many times.

Sample input:
aba
10

Sample output:
7

Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?