import sys,random from itertools import permutations from collections import deque from heapq import * input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) def Z_algorithm(s): N = len(s) Z_alg = [0]*N Z_alg[0] = N i = 1 j = 0 while i < N: while i+j < N and s[j] == s[i+j]: j += 1 Z_alg[i] = j if j == 0: i += 1 continue k = 1 while i+k < N and k + Z_alg[k]= i: if i < N-i: ans += 1 continue if S[Z[i]] < S[Z[i]+i]: ans += 1 else: assert S[Z[i]] > S[Z[i]+i] print(ans)