Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import math
import decimal


def main():

    N = int(input())
    ans = 0
    pn = [2]
    A = int(math.ceil(N**0.5)+1)

    if N >= 3:
        for L in range(3, A):
            chk = True
            for L2 in pn:
                if L % L2 == 0:
                    chk = False
            if chk == True:
                pn.append(L)
    elif N == 2:
        print(1)
        return
    else:
        print(0)
        return

    for i in pn:
        cnt = 0
        while(True):
            if N % i == 0:
                N /= i
                cnt += 1
            else:
                break

        for j in range(1, A):
            if cnt-j >= 0:
                ans += 1
                cnt -= j
            else:
                break

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import math
import decimal


def main():

    N = int(input())
    ans = 0
    A = int(math.ceil(N**0.5)+1)
    explist = []
    flag = False
    if N >= 3:
        for L in range(2, A):
            if N < L:
                break
            d = L
            cnt = 0
            while(True):
                if N % d == 0:
                    N /= d
                    cnt += 1
                    flag = True
                else:
                    break
            explist.append([d, cnt])
        for i in explist:
            c = i[1]
            for j in range(1, A):
                if c >= j:
                    ans += 1
                    c -= j
                else:
                    break
        if N >= A:
            ans += 1
        if flag:
            print(ans)
            return
        else:
            print(1)
            return
    elif N == 2:
        print(1)
        return
    else:
        print(0)
        return


if __name__ == '__main__':
    main()
### BUGGY CODE ###

n = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(min(A),max(A)+1):
  cnt = A.count(i)
  cnt += A.count(i-1)
  cnt += A.count(i+1)
  ans = max(ans,cnt) 
print(ans)
  

### FIXED CODE ###

n = int(input())
cnt = [0] * 100002
a = list(map(int, input().split()))
for v in a:
    cnt[v] += 1
    cnt[v+1] += 1
    cnt[v+2] += 1
    
print(max(cnt))
### BUGGY CODE ###

mn,jn=map(int,input().split())
mm=input()
mi_mm={}
go=[1 for i in range(mn+2)]
for i in range(mn):
    mi_mm.setdefault(mm[i],[])
    mi_mm[mm[i]]+=[i+1]

for ji in range(jn):
    ju=input().split()
    if ju[0] in mi_mm:
        if ju[1]=="L":
            for mi in mi_mm[ju[0]]:
                go[mi-1]+=go[mi]
                go[mi]=0
        else:
            for mi in mi_mm[ju[0]][::-1]:
                go[mi +1] += go[mi]
                go[mi] = 0

print(sum(go[1:mn+1]))

### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n, q = MI()
    s = SI()
    td = [SI().split() for _ in range(q)]
    ans = n
    # 左に落ちるゴーレムのうち、最右のインデックス
    l = -1
    r = n
    while l + 1 < r:
        m = (l + r) // 2

        def ok(m):
            for t, d in td:
                if s[m] == t: m += (d == "R") * 2 - 1
                if m == -1: return True
                if m == n: return False
            return False

        if ok(m): l = m
        else: r = m
    ans -= l + 1
    # 右に落ちるゴーレムのうち、最左のインデックス
    l = -1
    r = n
    while l + 1 < r:
        m = (l + r) // 2

        def ok(m):
            for t, d in td:
                if s[m] == t: m += (d == "R") * 2 - 1
                if m == -1: return False
                if m == n: return True
            return False

        if ok(m): r = m
        else: l = m
    ans -= n - r

    print(ans)

main()
### BUGGY CODE ###

n, p = map(int, input().split())
s = list(map(int, list(input())))[::-1]

if 10%p==0:
    result = 0
    for i in range(n):
        if s[i]%p==0:
            result += n-i
else:
    r = [0 for _ in range(p)]
    r[0] = 1
    t = 0
    ten = 1
    for i in range(n):
        t += (s[i]%p)*ten
        t %= p
        ten *= 10%p
        r[t] += 1
    result = 0
    for i in r:
        result += i*(i-1)//2
print(result)

### FIXED CODE ###

n, p = map(int, input().split())
s = list(map(int, list(input())))[::-1]

if 10%p==0:
    result = 0
    for i in range(n):
        if s[i]%p==0:
            result += n-i
else:
    r = [0 for _ in range(p)]
    r[0] = 1
    t = 0
    ten = 1
    for i in s:
        t = (t+i*ten)%p
        ten = (ten*10)%p
        r[t] += 1
    result = 0
    for i in r:
        result += i*(i-1)//2
print(result)
### BUGGY CODE ###

import sys
def main():
    l= sys.stdin.readline()
    N, K = list(map(int, l.split()))
    l = sys.stdin.readline()
    nums = list(map(lambda a:(int(a)+1)/2.0, l.split()))
    
    M = [sum(nums[:K])]
    for i in range(K, len(nums)):
        M.append(max(M[-1], sum(nums[i-K+1:i+1])))
    return M[-1]
if __name__ == "__main__":
    print(main())

### FIXED CODE ###

import sys
def main():
    l= sys.stdin.readline()
    N, K = map(int, l.split())
    
    l = sys.stdin.readline()
    nums = list(map(lambda a:(int(a)+1)/2.0, l.split()))
    
    M = sum(nums[:K])
    mx = M
    for i in range(K, len(nums)):
        #print(nums[i-K], nums[i])
        M = M - nums[i-K] + nums[i]

        if M > mx:
            mx = M
        
    return mx
if __name__ == "__main__":
    print(main())
### BUGGY CODE ###

n,w=map(int,input().split())
wv=[list(map(int,input().split())) for _ in range(n)]
wv.sort()
dp=[[0]*(w+1) for _ in range(n)]
for i in range(1,w+1):
    if i<wv[0][0]:
        dp[0][i]=0
    else:
        dp[0][i]=wv[0][1]
for i in range(1,n):
    for j in range(1,w+1):
        if wv[i][0]>j:
            dp[i][j]=dp[i-1][j]
        else:
            wleft=j-wv[i][0]
            dp[i][j]=max(wv[i][1]+dp[i-1][wleft],dp[i-1][j])
print(dp[-1][-1])

### FIXED CODE ###

n,w=map(int,input().split())
wv=[list(map(int,input().split())) for _ in range(n)]
#wv.sort()
dp=[[0]*(w+1) for _ in range(n)]
for i in range(1,w+1):
    if i<wv[0][0]:
        dp[0][i]=0
    else:
        dp[0][i]=wv[0][1]
for i in range(1,n):
    for j in range(1,w+1):
        if wv[i][0]>j:
            dp[i][j]=dp[i-1][j]
        else:
            wleft=j-wv[i][0]
            dp[i][j]=max(wv[i][1]+dp[i-1][wleft],dp[i-1][j])
print(dp[-1][-1])
### BUGGY CODE ###

n = int(input())
s = list(map(int, input().split()))
s.sort()
t = list(set(s))

for i in range(len(t)):
    s.remove(t[i])

if len(s) % 2 == 0:
    x = len(s)
else:
    x = len(s) + 1

print(n - x)

### FIXED CODE ###

n = int(input())
s = list(map(int, input().split()))
t = list(set(s))

for i in range(len(t)):
    s.remove(t[i])

if len(s) % 2 == 0:
    x = len(s)
else:
    x = len(s) + 1

print(n - x)
### BUGGY CODE ###

n = int(input())
tree = [[] for i in range(n+1)]

for i in range(1,n):
    u, v, w = map(int, input().split())
    tree[u].append((v, w))
    tree[v].append((u, w))

stack=[1]
visitted=[]
ans=[0]*n

while stack:
    cur = stack.pop()
    pre=ans[cur-1]
    visitted.append(cur)
    for v, w in tree[cur]:
        if v in visitted:
            continue
        #if v in stack:
        #    continue
        if w % 2 == 1:
            ans[v-1]=(pre+1)%2
        else:
            ans[v-1]=pre
        stack.append(v)

print(*ans, sep='\n')

### FIXED CODE ###

n = int(input())
tree = [[] for i in range(n+1)]

for i in range(1,n):
    u, v, w = map(int, input().split())
    tree[u].append((v, w))
    tree[v].append((u, w))

#print(tree)
stack=[1]
visitted={}
ans=[0]*n

while stack:
    cur = stack.pop()
    pre=ans[cur-1]
    visitted.setdefault(cur,1)
    #visitted.append(cur)
    for v, w in tree[cur]:
        if v in visitted:
            continue
        if w % 2 == 1:
            ans[v-1]=(pre+1)%2
        else:
            ans[v-1]=pre
        stack.append(v)

print(*ans, sep='\n')
### BUGGY CODE ###

from itertools import product
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
AB = sorted([a+b for a,b in product(A,B)],reverse=True)[:K]
ans = sorted([a+b for a,b in product(AB,C)],reverse=True)[:K]
for i in ans:
    print(i)

### FIXED CODE ###

from itertools import product
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
AB = sorted([a+b for a,b in product(A,B)],reverse=True)[:K]
ans = sorted([a+b for a,b in product(AB,C)],reverse=True)[:K]
for i in ans:
    print(i)
### BUGGY CODE ###

n=int(input())
s=sorted([input() for k in range(n)])
p=[]
if(len(set(s))==len(s)):
    for u in range(len(s)):
        print(s[u])
    exit()
else:
    s1=s2 = [m for m in sorted(list(set(s))) if s.count(m)>1]
    i = 2
    while(len(s2)!=0):
        s2 = [m for m in sorted(list(set(s))) if s.count(m)>i]
        if(len(s2) == 0):
            break
        else:
            s1 = s2
            i+=1

for j in s1:
    print(j)

### FIXED CODE ###

N = int(input())
d = {}
for _ in range(N):
  s = input()
  if(s not in d):
    d[s] = 1
  else:
    d[s] += 1
d2 = sorted(d.items(),key=lambda x:x[1], reverse=True)
s1=[]
s1.append(d2[0][0])
p=d2[0][1]
for t in d2[1:]:
  q=t[1]
  if(q==p):
    s1.append(t[0])
  else:
    break
s1=sorted(s1)
for i in s1:
  print(i)
### BUGGY CODE ###

H, W = map(int, input().split())
cnt = 0

for x in range(H):
    for y in range(W):
        if (x+y) % 2 == 0:
            cnt += 1
print(cnt)

### FIXED CODE ###


H, W = map(int, input().split())
ans = 1 if H == 1 or W == 1 else (H*W+1) // 2
print(ans)
### BUGGY CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from operator import itemgetter
from bisect import bisect,insort

def solve(n, ppp):
    q = sorted(enumerate(ppp),key=itemgetter(1),reverse=True)
    le = [-1,-1,n,n]
    ans = 0
    for i, p in q:
        l_i = bisect(le,i)
        LL = le[l_i-2]
        LR = le[l_i-1]
        RL = le[l_i]
        RR = le[l_i+1]
        ans += p*((LR-LL)*(RL-i)+(RR-RL)*(i-LR))
        insort(le,i)
    return ans


n = int(readline())
ppp = list(map(int,readline().split()))
print(solve(n, ppp))

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from operator import itemgetter

n = int(readline())
ppp = list(map(int,readline().split()))

def BIT_add(i,x):
    while i <= n:
        tree[i] += x
        i += i&(-i)

def BIT_sum(i):
    s = 0
    while i:
        s += tree[i]
        i -= i&(-i)
    return s

def BIT_search(x):
    # 二分探索。和がx以上となる最小のインデックス(>= 1)を返す
      i = 0
      s = 0
      step = 1<<(n.bit_length()-1)
      while step:
          if i+step <= n and s + tree[i+step] < x:
              i += step
              s += tree[i]
          step >>= 1
      return i+1

q = sorted(enumerate(ppp,1),key=itemgetter(1),reverse=True)
tree = [0]*(n+1)

ans = 0
for i, p in q:
    L = BIT_sum(i) # 左にある既に書き込んだ数の個数
    BIT_add(i,1)
    R = n-p-L # 右にある既に書き込んだ数の個数
    LL = BIT_search(L-1) if L >= 2 else 0
    LR = BIT_search(L) if L >= 1 else 0
    RL = BIT_search(L+2) if R >= 1 else n+1
    RR = BIT_search(L+3) if R >= 2 else n+1
    ans += p*((LR-LL)*(RL-i)+(RR-RL)*(i-LR))
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

n,m = map(int, input().split(' '))
a_list = list(map(int, input().split(' ')))
 
for i in range(m):
    p = max(a_list)
    a_list.remove(p)
    a_list.append(p // 2)
    
print(sum(a_list))

### FIXED CODE ###

import sys
import heapq
input = sys.stdin.readline

n,m = map(int, input().split(' '))
a_list = [-1 * int(i) for i in input().split() ]
heapq.heapify(a_list)
 
for _ in range(m):
    p = heapq.heappop(a_list)
    q = (-1*p //2) * (-1)
    heapq.heappush(a_list, q)    
    
print(-sum(a_list))
### BUGGY CODE ###

import heapq
import sys


def input(): return sys.stdin.readline().rstrip()


H, W = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
S = [list(input()) for i in range(H)]


def trans(h, w):
    return W*(h) + w


P = [(0, -1), (0, 1), (1, 0), (-1, 0)]

G = [[] for i in range(H*W)]
for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            for dx, dy in P:
                if 0 <= dx+i < H and 0 <= dy+j < W and S[dx+i][dy+j] == ".":
                    G[trans(i, j)].append((trans(dx+i, dy+j), 0))
                    G[trans(dx+i, dy+j)].append((trans(i, j), 0))
            for dx in range(-2, 3):
                for dy in range(-2, 3):
                    if dx != 0 or dy != 0:
                        if S[i][j] == "." and 0 <= dx+i < H and 0 <= dy+j < W and S[dx+i][dy+j] == ".":
                            G[trans(i, j)].append((trans(dx+i, dy+j), 1))
                            G[trans(dx+i, dy+j)].append((trans(i, j), 1))

D = [10**10 for i in range(H*W)]
D[trans(ch-1, cw-1)] = 0
que = []
heapq.heapify(que)
heapq.heappush(que, (0, trans(ch-1, cw-1)))

while que:
    cost, v = heapq.heappop(que)
    if D[v] < cost:
        continue
    for node, cost in G[v]:
        if D[node] > D[v] + cost:
            D[node] = D[v] + cost
            heapq.heappush(que, (D[node], node))

ans =D[trans(dh-1, dw-1)]

if ans == 10**10:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

import heapq
import sys


def input(): return sys.stdin.readline().rstrip()


H, W = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
data = [[0]*W for i in range(H)]

for i in range(H):
    S = input()
    for j in range(W):
        if S[j] == ".":
            data[i][j] = 1
        else:
            data[i][j] = 0


def trans(h, w):
    return W*(h) + w


P = [(0, -1), (0, 1), (1, 0), (-1, 0)]
DXY = []
for i in range(0, 3):
    for j in range(-2, 3):
        if i==0 and j==0:
            pass
        else:
            DXY.append((i,j))
            
G = [[] for i in range(H*W)]
H_L = [i for i in range(H)]
W_L = [i for i in range(W)]
for i in H_L:
    for j in W_L:
        if data[i][j] == 1:
            for dx, dy in P:
                if 0 <= dx+i < H and 0 <= dy+j < W and data[dx+i][dy+j] == 1:
                        u, v = trans(i, j), trans(dx+i, dy+j)
                        G[u].append((v, 0))
                        G[v].append((u, 0))
            for dx, dy in DXY:
                if 0 <= dx+i < H and 0 <= dy+j < W and data[dx+i][dy+j] == 1:
                        u, v = trans(i, j), trans(dx+i, dy+j)
                        G[u].append((v, 1))
                        G[v].append((u, 1))


D = [10**6+100 for i in range(H*W)]
D[trans(ch-1, cw-1)] = 0
que = []
heapq.heapify(que)
heapq.heappush(que, (0, trans(ch-1, cw-1)))

while que:
    cost, v = heapq.heappop(que)
    if D[v] < cost:
        continue
    for node, cost in G[v]:
        if D[node] > D[v] + cost:
            D[node] = D[v] + cost
            heapq.heappush(que, (D[node], node))

ans = D[trans(dh-1, dw-1)]

if ans == 10**6+100:
    print(-1)
else:
    print(ans)
### BUGGY CODE ###

import sys
input=sys.stdin.readline
N=int(input())
S=input()
Q=int(input())

A=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

n=1
while n<N:
    n*=2

seg=[set() for i in range(n*2)]
#print(seg)

for i in range(N):
    seg[n-1+i]=set(S[i])
    k=n-1+i
    while k>0:
        k=(k-1)//2
        seg[k]=(seg[k*2+1]|seg[k*2+2])
#print(seg)

#0indexでa番目の値をbに変更
def update(a,b):
    a+=n-1
    seg[a]=set(b)
    while a>0:
        a=(a-1)//2
        seg[a]=(seg[a*2+1]|seg[a*2+2])

#print(seg)

#A～B-1(0-index)までの累積和を求める
#1～2までの累積和なら(1,3,0,0,n)
#Kは接点番号？L,Rはその接点が[L,R)に対応づいていることを表す？
#外部からはquery(A,B,0,0,n)として呼び出す
def query(A,B,K,L,R):
    if K>=len(seg):
        return set()
    if R<=A or B<=L:
        return set()
    elif A<=L and R<=B:
        return seg[K]
    else:
        vl=query(A,B,K*2+1,L,(L+R)//2)
        vr=query(A,B,K*2+2,(L+R)//2,R)
        #print(vl,vr)
        return vl|vr
#print(n,len(seg))
#print("P",query(2,4,0,0,n),len(query(2,4,0,0,n)))
#update(3,"a")
#print(seg)
#print(query(2,4,0,0,n))
for i in range(Q):
    x,y,z=list(input().split())
    if x=="1":
        update(int(y)-1,z)
    else:
        print(len(query(int(y)-1,int(z),0,0,n)))


### FIXED CODE ###

import sys
input=sys.stdin.readline
N=int(input())
S=input()
Q=int(input())
D={}
A=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for i in range(26):
    D[A[i]]=i
n=1
while n<N:
    n*=2

seg=[0 for i in range(n*2)]
#print(seg)

for i in range(N):
    seg[n-1+i]=1<<D[S[i]]
    k=n-1+i
    while k>0:
        k=(k-1)//2
        seg[k]=(seg[k*2+1]|seg[k*2+2])
#print(list(bin(seg[0])).count("1"))

#0indexでa番目の値をbに変更
def update(a,b):
    a+=n-1
    seg[a]=1<<D[b]
    while a>0:
        a=(a-1)//2
        seg[a]=(seg[a*2+1]|seg[a*2+2])

#print(seg)

#A～B-1(0-index)までの累積和を求める
#1～2までの累積和なら(1,3,0,0,n)
#Kは接点番号？L,Rはその接点が[L,R)に対応づいていることを表す？
#外部からはquery(A,B,0,0,n)として呼び出す
def query(A,B,K,L,R):
    if K>=len(seg):
        return 0
    if R<=A or B<=L:
        return 0
    elif A<=L and R<=B:
        return seg[K]
    else:
        vl=query(A,B,K*2+1,L,(L+R)//2)
        vr=query(A,B,K*2+2,(L+R)//2,R)
        #print(vl,vr)
        return vl|vr
#print(n,len(seg))
#print("P",query(2,4,0,0,n),len(query(2,4,0,0,n)))
#update(3,"a")
#print(seg)
#print(query(2,4,0,0,n))
for i in range(Q):
    x,y,z=list(input().split())
    if x=="1":
        update(int(y)-1,z)
    else:
        print(list(bin(query(int(y)-1,int(z),0,0,n))).count("1"))
### BUGGY CODE ###

import numpy as np
A, B = map(int, input().split())
l = max(len(bin(A)[2:]), len(bin(B)[2:]))
arr = np.zeros(l)
ans = 0
for i in range(A, B+1):
    c = np.array(list(map(int, bin(i)[2:])))
    arr[l-len(c):] += c
arr = (arr % 2).astype(np.int8)
ans = int(''.join(map(str, arr)), base=2)
print(ans)


### FIXED CODE ###

def F(N):
    if ((N+1) // 2) % 2 == 0:
        bit = 0
    else:
        bit = 1
    if N % 2 == 0:
        return bit ^ N
    else:
        return bit

A, B = map(int, input().split())
ans = F(A-1) ^ F(B)
print(ans)
### BUGGY CODE ###

# coding: utf-8

from itertools import product as prod
import sys
input = sys.stdin.readline

mod = int(1e9 + 7)

def f2(K, D):
    l = len(K)
    dp = [[[0] * D for _ in range(2)] for _ in range(l + 1)]
    dp[0][0][0] = 1

    for i, j, d in prod(range(l), range(2), range(D)):
        maxk = 9 if j else int(K[i])
        dpij = dp[i][j]
        dpi1 = dp[i + 1]
        for k in range(maxk + 1):
            dpi1j = dpi1[j or k < maxk]
            d_ = (d + k) % D
            dpi1j[d_] += dpij[d]
            if dpi1j[d_] > mod:
                dpi1j[d_] -= mod
    # K = 0 の場合が含まれるので -1
    return((dp[-1][0][0] + dp[-1][1][0] - 1 + mod) % mod)

K = input().rstrip() # 1 <= K <= 10^10000
D = int(input()) # 1 <= D <= 100
print(f2(K, D))


### FIXED CODE ###

# coding: utf-8

import sys
input = sys.stdin.readline

mod = int(1e9 + 7)

def f(K, D):
    l = len(K)
    dp = [[[0] * D for _ in range(2)] for _ in range(l + 1)]
    dp[0][0][0] = 1
    for i in range(l):
        ki = int(K[i])
        for j in range(2):
            uki = 9 if j else ki
            dpij = dp[i][j]
            for d in range(D):
                for k in range(uki + 1):
                    dpij_ = dp[i + 1][j or k < ki]
                    d_ = (d + k) % D
                    dpij_[d_] += dpij[d]
                    dpij_[d_] %= mod
    # K = 0 の場合が含まれるので -1
    return((dp[-1][0][0] + dp[-1][1][0] - 1 + mod) % mod)

K = input().rstrip() # 1 <= K <= 10^10000
D = int(input()) # 1 <= D <= 100

print(f(K, D))
### BUGGY CODE ###

import bisect

def ceil_number(n):
    return math.floor(n)

N,M = map(int,input().split())
Price_List = sorted(list(map(int,input().split())))
for i in range(M):
    New_Price = Price_List.pop(-1)
    Price_List.insert(bisect.bisect(Price_List,New_Price//2),New_Price//2)
print(sum(Price_List))


### FIXED CODE ###

import bisect
 
N,M = map(int,input().split())
Price_List = list(map(int,input().split()))
Price_List.sort()
for i in range(M):
    New_Price = Price_List.pop(-1)//2
    Price_List.insert(bisect.bisect(Price_List,New_Price),New_Price)
print(sum(Price_List))
### BUGGY CODE ###

N = int(input())
List = list(map(int,input().split()))

cut = N
check =0
for i in range(1,N+1):
    for k in range(1,i+1):
        if List[k-1]<List[i-1]:
           check = 1
    if check==1:
        cut -= 1
    check = 0

print(cut)


### FIXED CODE ###

N = int(input())
List = list(map(int,input().split()))


cut = N
check =0
min = N

for i in range(1,N+1):
    
    if List[i-1]<=min:
        min = List[i-1]
        
    else:
        cut -=1

    




print(cut)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.append(10 ** 10)
B.append(10 ** 10)
C.append(10 ** 10)

A.sort()
B.sort()
C.sort()

i, j, k = 0, 0, 0
count = 0
total = []
result = 0

while i < N:
    while C[i] > B[j] and j < N:
        while B[j] > A[k] and k < N:
            count += 1
            k += 1
        total.append(count)
        j += 1
    result += sum(total)
    i += 1

print(result)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.append(10 ** 10)
B.append(10 ** 10)
C.append(10 ** 10)

A.sort()
B.sort()
C.sort()

i, j, k = 0, 0, 0
count = 0
total = 0
result = 0

while i < N:
    while C[i] > B[j] and j < N:
        while B[j] > A[k] and k < N:
            count += 1
            k += 1
        total += count
        j += 1
    result += total
    i += 1

print(result)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)

n = int(input())
mod = 10**9 + 7
A, G, C, T = 'A', 'G', 'C', 'T'
count = 0


def seq(length, s3, s2, s1):
    if length == n:
        global count
        count += 1
        count %= mod
        return

    if [s2, s1] == [A, G]:
        for x in [A, G, T]:
            seq(length+1, s2, s1, x)

    elif [s2, s1] == [A, C]:
        for x in [A, C, T]:
            seq(length+1, s2, s1, x)

    elif [s2, s1] == [G, A]:
        for x in [A, G, T]:
            seq(length+1, s2, s1, x)

    elif [s3, s1] == [A, G]:
        for x in [A, G, T]:
            seq(length+1, s2, s1, x)

    elif [s3, s2] == [A, G]:
        for x in [A, G, T]:
            seq(length+1, s2, s1, x)

    else:
        for x in [A, C, G, T]:
            seq(length+1, s2, s1, x)


seq(0, T, T, T)
print(count)

### FIXED CODE ###

from collections import defaultdict

n = int(input())
mod = 10**9 + 7
DP = [defaultdict(int) for _ in range(n+1)]
DP[0]['TTT'] = 1

for length in range(n):
    for seq, count in DP[length].items():

        if seq[1:] in ['AG', 'GA'] or seq[:2] == 'AG' or seq[0]+seq[2] == 'AG':
            for ns in 'AGT':
                new_seq = seq[1:] + ns
                DP[length+1][new_seq] += count
                DP[length + 1][new_seq] %= mod

        elif seq[1:] == 'AC':
            for ns in 'ACT':
                new_seq = seq[1:] + ns
                DP[length + 1][new_seq] += count
                DP[length + 1][new_seq] %= mod

        else:
            for ns in 'ACGT':
                new_seq = seq[1:] + ns
                DP[length + 1][new_seq] += count
                DP[length + 1][new_seq] %= mod

ans = sum(DP[n].values()) % mod
print(ans)
### BUGGY CODE ###

for e in iter(input,'0 0'):
 H,W=map(int,e.split())
 s=[[*map(int,input().split())]for _ in[0]*H]
 a=0
 for x in range(2**H):
     t=[[c^int(b)for c in r]for r,b in zip(s,bin(x)[2:].zfill(H))]
     a=max(a,sum(max(sum(c),H-sum(c))for c in zip(*t)))
 print(a)


### FIXED CODE ###

def v():
 for e in iter(input,'0 0'):
  r=int(e.split()[0])
  d=[int(''.join(x),2)for x in zip(*[input().split()for _ in[0]*r])]
  a=0
  for m in range(1<<~-r):
   t=0
   for s in d:
    c=bin(m^s).count('1')
    t+=max(c,r-c)
   if a<t:a=t
  print(a)
if'__main__'==__name__:v()