function repeatedString(s, n) {
if (s === 'a') return n;
if (!s.includes('a')) return 0;
const ocurrences = s.match(/a/g).length;
const repeatTimes = n / s.length;
const c = n - s.length * Math.floor(repeatTimes);
const remanentStr = s.substr(0, c).match(/a/g) || [];
return Number.isInteger(repeatTimes)
? ocurrences * repeatTimes
: (ocurrences * Math.floor(repeatTimes)) + remanentStr.length;
}