Repeated String

  • + 0 comments

    import sys

    s = input().strip() n = int(input().strip())

    l = len(s) if(l==1 and s=='a'): print(n) else: c = s.count('a') c *= n//l s = s[:(n%l)] c+=s.count('a') print(c)