#include <stdio.h>
long repeatedString(char s[], long n) {
long count_a = 0;
long len = 0;
// Count the number of 'a' in the given string s
for (int i = 0; s[i] != '\0'; i++) {
if (s[i] == 'a') {
count_a++;
}
len++;
}
// Calculate the number of times the string s is repeated completely
long repetitions = n / len;
// Calculate the remaining characters after complete repetitions
long remaining_chars = n % len;
// Count the number of 'a' in the remaining characters
for (int i = 0; i < remaining_chars; i++) {
if (s[i] == 'a') {
count_a++;
}
}
// Calculate the total number of 'a' in the first n characters
return (repetitions * count_a);
}
int main() {
char s[] = "abcac";
long n = 10;
long result = repeatedString(s, n);
printf("%ld\n", result);
return 0;
}