#NEWLINE# def powerstring_by_border( u ) : #NEWLINE# #INDENT# 'Power string by Knuth-Morris-Pratt\n\n    :param x: string\n    :returns: largest k such that there is a string y with x = y^k\n    :complexity: O(len(x))\n    ' #NEWLINE# L = maximum_border_length ( u ) #NEWLINE# n = len ( u ) #NEWLINE# if ( ( n % ( n - L [ ( - 1 ) ] ) ) == 0 ) : #NEWLINE# #INDENT# return ( n // ( n - L [ ( - 1 ) ] ) ) #NEWLINE# #UNINDENT# return 1