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

s = input()

ans = 0

while True:
    if s.count('01') != 0:
        ans += s.count('01')*2
        s=s.replace('01', '')
    elif s.count('10') != 0:
        ans += s.count('10')*2
        s=s.replace('10', '')
    else:
        break

print(ans)


### FIXED CODE ###

S = input()
print(min(S.count("0"),S.count("1"))*2)
### BUGGY CODE ###

A, B, K = map(int,input().split())
for i in range(A, B + 1):
  if i - A < K or B - i < K:
    print(i)

### FIXED CODE ###

A, B, K = map(int,input().split())
if B - A < 2 * K:
    for i in range(A, B + 1):
        print(i)
else:
    for i in range(A, A + K):
        print(i)
    for i in range(B - K + 1, B + 1):
        print(i)
### BUGGY CODE ###

#coding:utf-8
import math
from functools import reduce

K=int(input())
result=0
for i in range(K):
	for j in range(K):
		for k in range(K):
			result+=reduce(math.gcd,[i+1,j+1,k+1])

print(result)

### FIXED CODE ###

#coding:utf-8
from math import*
K=int(input())
result=0
for i in range(1,K+1):
	for j in range(1,K+1):
		for k in range(1,K+1):
			result+=gcd(gcd(i,j),k)

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

import sys
from heapq import heappop, heappush


def dijkstra(links, n, l):
    dists = []

    F9 = (1 << 9) - 1
    F30 = (1 << 30) - 1
    INF = 10 ** 18

    for s in range(n):

        q = [s]
        fixed = [-1] * n
        upper = [INF] * n

        while q:
            item = heappop(q)

            v = item & F9
            if fixed[v] != -1:
                continue

            count = item >> 39
            used = (item >> 9) & F30
            fixed[v] = count

            for u, c in links[v]:
                if l - used < c:
                    new_item = ((count + 1) << 39) | (c << 9) | u
                else:
                    new_item = (count << 39) | ((used + c) << 9) | u
                if new_item >= upper[u]:
                    continue
                upper[u] = new_item
                heappush(q, new_item)

        dists.append(fixed)

    return dists


n, m, l = list(map(int, input().split()))
lines = sys.stdin.readlines()

links = [set() for _ in range(n)]

for line in lines[:m]:
    a, b, c = map(int, line.split())
    a -= 1
    b -= 1
    if l < c:
        continue
    links[a].add((b, c))
    links[b].add((a, c))

dists = dijkstra(links, n, l)
buf = []

for line in lines[m + 1:]:
    s, t = map(int, line.split())
    buf.append(dists[s - 1][t - 1])

print('\n'.join(map(str, buf)))


### FIXED CODE ###

import sys

n, m, l = list(map(int, input().split()))
lines = sys.stdin.readlines()
INF = 10 ** 18

dists = [[INF] * n for _ in range(n)]

for i in range(n):
    dists[i][i] = 0

for line in lines[:m]:
    a, b, c = map(int, line.split())
    a -= 1
    b -= 1
    if c > l:
        continue
    dists[a][b] = c
    dists[b][a] = c

for k in range(n):
    dk = dists[k]
    for i in range(n):
        di = dists[i]
        for j in range(n):
            new_dist = di[k] + dk[j]
            if new_dist > l:
                continue
            if di[j] > new_dist:
                di[j] = new_dist

refuels = [[1 if dist < INF else INF for dist in row] for row in dists]

for k in range(n):
    rk = refuels[k]
    for i in range(n):
        ri = refuels[i]
        for j in range(n):
            new_dist = ri[k] + rk[j]
            if ri[j] > new_dist:
                ri[j] = new_dist

buf = []

for line in lines[m + 1:]:
    s, t = map(int, line.split())
    refuel = refuels[s - 1][t - 1]
    buf.append(-1 if refuel == INF else refuel - 1)

print('\n'.join(map(str, buf)))
### BUGGY CODE ###

import sys
import bisect
import copy
sys.setrecursionlimit(10 ** 6)
def input():
    return sys.stdin.readline()[:-1]

def dfs(v,prev = -1):
    x = As[v]
    if prev != -1 and x > LIS[prev][-1]:
        l = copy.copy(LIS[prev])
        l.append(x)
        LIS[v] = l
    elif prev != -1:
        l = copy.copy(LIS[prev])
        l[bisect.bisect_left(l, x)] = x
        LIS[v] = l
    else:
        LIS[v] = [x]
    ans_array[v] = len(LIS[v])
    for u in graph[v]:
        if u == prev:
            continue
        dfs(u,v)

N = int(input())
As = list(map(int,input().split()))
graph = [[] for _ in range(N)]

for i in range(N-1):
    a,b = list(map(int,input().split()))
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
LIS = [[] for i in range(N)]
ans_array = [0] * N
dfs(0)
for i in range(N):
    print(ans_array[i])


### FIXED CODE ###

import sys
import bisect
import copy
sys.setrecursionlimit(10 ** 6)
def input():
    return sys.stdin.readline()[:-1]
inf = 10**9+1

def dfs(v,prev = -1):
    x = As[v]
    if len(LIS) == 0 or x > LIS[-1]:
        old = inf
        i = len(LIS)
        LIS.append(x)
    else:
        i = bisect.bisect_left(LIS, x)
        old = LIS[i]
        LIS[i] = x

    a = len(LIS)
    ans_array[v] = a
    for u in graph[v]:
        if u == prev:
            continue
        dfs(u,v)
    if old == inf:
        LIS.pop(-1)
    else:
        LIS[i] = old

N = int(input())
As = list(map(int,input().split()))
graph = [[] for _ in range(N)]

for i in range(N-1):
    a,b = list(map(int,input().split()))
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
LIS = []
ans_array = [0] * N
dfs(0)
for i in range(N):
    print(ans_array[i])
### BUGGY CODE ###

import numpy as np
n,t=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
dp1=np.zeros((n+1,t),int)
dp2=np.zeros((n+2,t),int)
# dp1[i][j]:0<=i<=n:i個目までの料理で考えたとき（i個の料理）、時間j以内で食べられるおいしさの総和
# dp2[i][j]:1<=i<=n+1:i個目以降の料理で考えたとき（n-i+1個の料理）、時間j以内で食べられるおいしさの総和
for i in range(n):
  a,b=ab[i]
  dp1[i+1,:a]=dp1[i,:a]
  dp1[i+1,a:]=np.maximum(dp1[i,a:],dp1[i,:-a]+b)
  j=n-i
  a,b=ab[j-1]
  dp2[j,:a]=dp2[j+1,:a]
  dp2[j,a:]=np.maximum(dp2[j+1,a:],dp2[j+1,:-a]+b)
ans=0
for i in range(1,n+1):# i個目の料理を最後に食べるとするとき。
  ai=max([dp1[i-1][j]+dp2[i+1][t-1-j] for j in range(t)])
  ans=max(ans,ai+ab[i-1][1])
print(ans)



### FIXED CODE ###

n,t=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
ab.sort(key=lambda x:x[0])
import numpy as np
ans=0
dp=np.zeros(t,np.int64)
# dp[i]:時間合計i以内に食べれる料理のおいしさ総和の最大
for i in range(n):
  a,b=ab[i]
  ans=max(ans,dp[-1]+b)
  dp[a:]=np.maximum(dp[a:],dp[:-a]+b)
print(ans)
### BUGGY CODE ###

N,W=map(int,input().split())
w=[]
v=[]
for i in range(N):
  w_,v_=map(int,input().split())
  w.append(w_)
  v.append(v_)
M=sum(v)
dp=[[float('inf')]*(M+1) for i in range(N+1)]
dp[0][0]=0

for i in range(N):
  for j in range(M+1):
    if j>=v[i]:
      dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i])
    else:
      dp[i+1][j]=dp[i][j]
ans=0
for i in range(M+1):
  if dp[N][i]<=W:
    ans=max(ans,i)
    
print(ans)
    

### FIXED CODE ###

N,W=map(int,input().split())
w=[]
v=[]
for i in range(N):
  w_,v_=map(int,input().split())
  w.append(w_)
  v.append(v_)
M=sum(v)
dp=[[float('inf')]*(M+1) for i in range(N+1)]
dp[0][0]=0

for i in range(N):
  for j in range(M+1):
    if j>=v[i]:
      dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i])
    else:
      dp[i+1][j]=dp[i][j]
ans=0
for i in range(M+1):
  if dp[N][i]<=W:
    ans=max(ans,i)
    
print(ans)
### BUGGY CODE ###

N = int(input())
S = input()
ans = 0

Klist = [N-1]
IJ = list()
for i in range(N-2):
    for j in range(i+1, N-1):
        if not S[i] == S[j]:
            IJ.append((i, j))
            Klist.append(j)
K = sorted(list(set(Klist)), reverse=True)
if 0 in K:
    K.remove(0)
if 1 in K:
    K.remove(1)
for ij in IJ:
    i, j = ij
    for k in K:
        if not j < k:
            break
        if S[j] == S[k]:
            continue
        if S[i] == S[k]:
            continue
        if j-i == k-j:
            continue
        ans += 1
print(ans)

### FIXED CODE ###

N = int(input())
S = input()
ans = S.count("R") * S.count("G") * S.count("B")
for i in range(N):
    for j in range(i, N):
        k = 2*j - i
        if N > k and S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
            ans -= 1
print(ans)
### BUGGY CODE ###

import numpy as np
import sys
import math
read = sys.stdin.readline

N = int(read().rstrip())
A = list(map(int,read().rstrip().split()))
da = []
for i , a in enumerate(A):
    da.append([i,a])

sumN = [0] * N
for i , a in enumerate(A):
    sumN[i] = i + a + 1


newA = sorted(da , key = lambda x:(x[1]))
ans = 0
for s in sumN :
    if s > 200000:
        continue

    for a in newA :
        if s + a[1] > 200000:
            break

        if s  + a[1]  == a[0] + 1:
            ans += 1

print(ans)


### FIXED CODE ###

import numpy as np
import sys
import math
read = sys.stdin.readline

N = int(read().rstrip())
A = list(map(int,read().rstrip().split()))
da = []
for i , a in enumerate(A):
    da.append([i,a])

dR = {}
dL = {}

ans = 0
for d in reversed(da):
    r = d[0] + d[1] + 1
    l = d[0] - d[1] + 1 
    if r in dR:
        dR[r] += 1
    else:
        dR[r] = 1

    if r in dL:
        ans += dL[r]

    if l in dL :
        dL[l] += 1
    else:
        dL[l] = 1  

print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10000)
from collections import deque
N, Q = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N-1)]
PX = [list(map(int, input().split())) for _ in range(Q)]

chil = [[] for _ in range(N+1)]
count = [0]*(N+1)

for ab in AB:
    chil[ab[0]].append(ab[1])
    chil[ab[1]].append(ab[0])

def cleanse(fromN, toN):
    chil[toN].remove(fromN)
    if len(chil[toN])==0:
        return
    for node in chil[toN]:
        cleanse(toN, node)

for node in chil[1]:
    cleanse(1, node)

for px in PX:
    count[px[0]] += px[1]

for parent in range(1, N+1):
    for child in chil[parent]:
        count[child] += count[parent]

print(*count[1:])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
N, Q = map(int, input().split())

edges = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

points = [0]*N
for _ in range(Q):
    p, x = map(int, input().split())
    points[p-1] += x

def dfs(v, par):
    for nv in edges[v]:
        if nv == par:
            continue
        points[nv] += points[v]
        dfs(nv, v)

dfs(0, -1)

print(*points)
### BUGGY CODE ###

from heapq import*
L,R=[],[]
n=int(input())
B=0
cnt=0
for i in range(n):
    I=input()
    if I[0]=="1":
        a,b,c=map(int,I.split())
        B+=c
        cnt+=1
        if cnt%2:
            x=heappushpop(R,b)
            heappush(L,-x)
        else:
            x=heappushpop(L,-b)
            heappush(R,-x)
    else:
        med=-L[0]
#        print(L,R)
        print(med,med*(len(L)-len(R))+sum(L)+sum(R)+B)

### FIXED CODE ###

from heapq import*
L,R=[],[]
n=int(input())
B=0
cnt=0
l,r=0,0
for i in range(n):
    I=input()
    if I[0]=="1":
        a,b,c=map(int,I.split())
        B+=c
        cnt+=1
        
        if cnt%2:
            x=heappushpop(R,b)
            r+=b-x
            heappush(L,-x)
            l+=-x
        else:
            x=heappushpop(L,-b)
            l+=-b-x
            heappush(R,-x)
            r+=-x
        #print(L,R,l,r)
        #print(b,x)
    else:
        med=-L[0]
#        print(L,R)
#        print(l,r)
        print(med,cnt%2*med+B+l+r)
### BUGGY CODE ###

n = int(input())
s = []
for _ in range(n):
    x = input()
    if not x in s:
        s.append(x)
print(len(s))

### FIXED CODE ###

n = int(input())
s = set()
for _ in range(n):
    s. add(input())
print(len(s))
### BUGGY CODE ###

from collections import defaultdict, Counter
import math
from bisect import bisect_left, bisect_right
import numpy as np

#### START
n = int(input())
a = list(map(int,input().split()))

ans = 10**100
for i in range(1, n):
    if ans>abs(sum(a[:i])-sum(a[i:])):
        ans = abs(sum(a[:i])-sum(a[i:]))

print(ans)

### FIXED CODE ###


from collections import defaultdict, Counter
import math
from bisect import bisect_left, bisect_right
import numpy as np

#### START
n = int(input())
a = list(map(int,input().split()))

ans = 10**100
res = np.cumsum(a)

print(min([abs(res[-1]-res[i]-res[i]) for i in range(len(res)-1)]))
### BUGGY CODE ###

from operator import itemgetter
n,q=map(int,input().split())
c=list(map(int,input().split()))
l=[list(map(int,input().split())) for i in range(q)]
l2=sorted(l,key=itemgetter(1))

L=[-1 for i in range(max(c))]

class Bit:
  def __init__(self,n):
    self.size=n
    self.tree=[0]*(n + 1)
    self.depth=n.bit_length()

  def sum(self,i):
    s=0
    while i>0:
      s+=self.tree[i]
      i-=i&-i
    return s

  def add(self,i,x):
    while i<=self.size:
      self.tree[i]+=x
      i+=i&-i

BIT=Bit(n+1)

ans={}
ct=0
for i in range(q):
  while ct<=l2[i][1]:
    if L[c[ct-1]-1]!=-1:
      BIT.add(L[c[ct-1]-1],-1)
    L[c[ct-1]-1]=ct+1
    BIT.add(ct+1,1)
    ct+=1
  ans[l2[i][0]*10**6+l2[i][1]]=BIT.sum(l2[i][1]+1)-BIT.sum(l2[i][0])

for i in range(q):
  print(ans[l[i][0]*10**6+l[i][1]])

### FIXED CODE ###

n,q=map(int,input().split())
c=list(map(int,input().split()))
l=[list(map(int,input().split())) for i in range(q)]
for i in range(q):
  l[i].append(i)
l2=sorted(l,key=lambda x:x[1])

L=[-1]*(5*10**5+1)

class Bit:
  def __init__(self,n):
    self.size=n
    self.tree=[0]*(n + 1)
    self.depth=n.bit_length()

  def sum(self,i):
    s=0
    while i>0:
      s+=self.tree[i]
      i-=i&-i
    return s

  def add(self,i,x):
    while i<=self.size:
      self.tree[i]+=x
      i+=i&-i

BIT=Bit(n+1)

ans=[0]*q
ct=0
for i in range(q):
  while ct<=l2[i][1]:
    if L[c[ct-1]-1]!=-1:
      BIT.add(L[c[ct-1]-1],-1)
    L[c[ct-1]-1]=ct+1
    BIT.add(ct+1,1)
    ct+=1
  ans[l2[i][2]]=BIT.sum(l2[i][1]+1)-BIT.sum(l2[i][0])

for i in range(q):
  print(ans[i])
### BUGGY CODE ###

A, B, K = map(int, input().split())

for i in range(A, B+1):
    if i < A + K or i > B - K:
        print(i)

### FIXED CODE ###

A, B, K = map(int, input().split())

if B - A > 2 * K:
    for i in range(A, A + K):
        print(i)
    for i in range(B - K+1, B+1):
        print(i) 
else:
    for i in range(A, B+1):
        if i < A + K or i > B - K:
            print(i)
### BUGGY CODE ###

from heapq import*
(N, M), *t = [map(int, s.split()) for s in open(0)]
q, z = [], 0
v = [q for _ in [0] * 10**5]
for a, b in t:
    v[a - 1] += b,
for i in v[:M]:
    for j in i:
        heappush(q, -j)
    z += -heappop(q)
print(z)

### FIXED CODE ###

from heapq import*
(N, M), *t = [map(int, s.split()) for s in open(0)]
q = [0] * 10**5
v = [[] for _ in q]
for a, b in t:
    v[a - 1] += b,
z = 0
for i in v[:M]:
    for j in i:
        heappush(q, -j)
    z += -heappop(q)
print(z)
### BUGGY CODE ###

S = input()
n = len(S)
dp = [0 for _ in range(n+1)]
count = [0 for _ in range(2019)]
count[0] = 1
for i in range(1,n+1):
    dp[i] = (dp[i-1]+int(S[n-i])*10**(i-1)) % 2019
    count[dp[i]] += 1

for i in range(2019):
    count[i] = count[i]*(count[i]-1)/2

print(int(sum(count)))

### FIXED CODE ###

S = input()
n = len(S)
dp = [0 for _ in range(n+1)]
count = [0 for _ in range(2019)]
count[0] = 1
p=1
for i in range(1,n+1):
    dp[i] = (dp[i-1]+int(S[n-i])*p) % 2019
    p = p*10%2019
    count[dp[i]] += 1

for i in range(2019):
    count[i] = count[i]*(count[i]-1)/2

print(int(sum(count)))
### BUGGY CODE ###

import sys
input=sys.stdin.readline

def main():
    S = input().strip()
    ans = 0
    while 1:
        i = S.find("ABC")
        if i < 0:
            break
        li = 0
        for l in range(i-1,-1,-1):
            if S[l] == "A":
                li += 1
            else:
                break
        ri = 0
        for r in range(i+3,len(S)-1,2):
            if S[r] == "B" and S[r+1] == "C":
                ri += 1
            else:
                break
        x = min(li, ri)
        S = S[:i-x] + "BC"*(x+1) + "A"*(x+1) + S[i+3 + x*2:]
        ans += 1 if x == 0 else (x+1)**2
        
    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input=sys.stdin.readline

def main():
    S = input().strip()
    S = S.replace("BC","D")
    ans = 0
    a = 0
    for c in S:
        if c == "A":
            a += 1
        elif c == "D":
            ans += a
        else:
            a = 0
        
    print(ans)

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

from heapq import heappop, heappush
from itertools import product

X, Y, Z, K = map(int, input().split())
*A, = map(int, input().split())
*B, = map(int, input().split())
*C, = map(int, input().split())
A.sort(reverse=True)

D = [i+j for j in C for i in B]
D.sort(reverse=True)

q = []
for i, j in product(A, D):
    heappush(q, -(i+j))

for _ in range(K):
    print(-heappop(q))

### FIXED CODE ###

from heapq import heappush, heappop

X, Y, Z, K = map(int, input().split())
*A, = map(int, input().split())
*B, = map(int, input().split())
*C, = map(int, input().split())
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

# x以上のものがK個あるならOK
def f(x):
    cnt = 0
    for i in A:
        for j in B:
            for k in C:
                if i+j+k<x:break
                cnt += 1
                if cnt>=K:
                    return True
    return False

def get_boarder():
    l, r = 0, A[0]+B[0]+C[0]
    while r-l>1:
        m = (l+r)//2
        if f(m):
            l = m
        else:
            r = m
    return l

boarder = get_boarder()
q = []
for i in A:
    for j in B:
        for k in C:
            if i+j+k<boarder:break
            heappush(q, -(i+j+k))

for _ in range(K):
    print(-heappop(q))
### BUGGY CODE ###

N = int(input())
power = 1
for i in range(1, N + 1):
    power *= i
print(power % (10**9 + 7))

### FIXED CODE ###

import math
N = int(input())
print(math.factorial(N) % (10**9 + 7))
### BUGGY CODE ###

from collections import deque
n = int(input())
Ps = list(map(lambda x: int(x)-1, input().split()))
cost = [min(min(i, n-1-i), min(j, n-1-j)) for i in range(n) for j in range(n)]
DIRC = [(-1, 0), (0, 1), (1, 0), (0, -1)]
exist = [1]*(n**2)


def to_idx(p):
    i, j = divmod(p, n)
    return i, j


def to_v(i, j):
    return i*n+j


def bfs(init_v):
    next_v = deque([to_idx(init_v)])
    exist[init_v] = 0
    while next_v:
        i, j = next_v.popleft()
        for di, dj in DIRC:
            x, y = i+di, j+dj
            if x < 0 or y < 0 or n <= x or n <= y:
                continue
            c = cost[to_v(i, j)]+exist[to_v(i, j)]
            if cost[to_v(x, y)] <= c:
                continue
            cost[to_v(x, y)] = c
            next_v.append((x, y))


ans = 0
for p in Ps:
    if not cost[p]:
        bfs(p)
        continue
    ans += cost[p]
    bfs(p)
print(ans)

### FIXED CODE ###

from collections import deque
n = int(input())
Ps = list(map(lambda x: int(x)-1, input().split()))
cost = [min(i, n-1-i, j, n-1-j) for i in range(n) for j in range(n)]
exist = [1]*(n**2)


def to_idx(p):
    return divmod(p, n)


def to_v(i, j):
    return i*n+j


def bfs(init_v):
    next_v = deque([init_v])
    exist[init_v] = 0
    while next_v:
        v = next_v.popleft()
        i, j = to_idx(v)
        if 0 < i:
            v2 = v-n
            if cost[v2] > cost[v]+exist[v]:
                cost[v2] = cost[v]+exist[v]
                next_v.append(v2)

        if i < n-1:
            v2 = v+n
            if cost[v2] > cost[v]+exist[v]:
                cost[v2] = cost[v]+exist[v]
                next_v.append(v2)

        if 0 < j:
            v2 = v-1
            if cost[v2] > cost[v]+exist[v]:
                cost[v2] = cost[v]+exist[v]
                next_v.append(v2)

        if j < n-1:
            v2 = v+1
            if cost[v2] > cost[v]+exist[v]:
                cost[v2] = cost[v]+exist[v]
                next_v.append(v2)

ans = 0
for p in Ps:
    ans += cost[p]
    bfs(p)
print(ans)
### BUGGY CODE ###

def main():
    N = int(input())
    P = list(map(int, input().split()))

    ans = 0
    min = N+1

    while len(P) != 0:
        p = P.pop(0)
        if min > p:
            min = p
            ans+=1


    print(ans)

    return 0

if __name__ == '__main__':
    main()


### FIXED CODE ###

import bisect
import numpy as np

def main():
    N = int(input())
    P = list(map(int, input().split()))


    ans = 1
    f = P[0]

    for i in range(1, N):
        f_o = P[i]
        if f >= f_o:
            ans+=1
            f = f_o
    print(ans)
    return 0


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

# coding: utf-8


def main():
    n, m = map(int, raw_input().split())

    l = [map(int, raw_input().split()) for _ in xrange(m)]

    la = []
    lb = []
    for ab in l:
        if ab[0] == 1:
            la.append(ab[1])
        if ab[1] == n:
            lb.append(ab[0])

    for a in la:
        if a in lb:
            print "POSSIBLE"
            return

    print "IMPOSSIBLE"

main()


### FIXED CODE ###

# coding: utf-8


def main():
    n, m = map(int, raw_input().split())

    s = [0] * 200010
    t = [0] * 200010
    for _ in xrange(m):
        a, b = map(int, raw_input().split())
        if a == 1:
            s[b] = True
        if b == n:
            t[a] = True

    for i in xrange(1, n+1):
        if s[i] and t[i]:
            print "POSSIBLE"
            return

    print "IMPOSSIBLE"

main()
### BUGGY CODE ###

import queue

def push(n, dist, dist_list):
	if dist_list[n] > dist:
		dist_list[n] = dist
		q.put(n)



q = queue.Queue()
n, x, y = [int(i) for i in input().split()]
result = [0] * (n-1)

for p in range(n):
	dist_list = [111111] * n
	dist = 0
	q.put(p)
	dist_list[p] = dist 
	while not q.empty():
		p = q.get()
		dist = dist_list[p]
		if p+1 < n: push(p+1, dist+1, dist_list)
		if p-1 >= 0: push(p-1, dist+1, dist_list)
		if p == (x-1): push(y-1, dist+1, dist_list)
		if p == (y-1): push(x-1, dist+1, dist_list)
	
	for i in dist_list:
		if i != 0:
			result[i-1] += 1

for ans in result:
	print(ans//2)
		






### FIXED CODE ###

n, x, y = [int(i) for i in input().split()]
# 0 index is 1 distance
result = [0] * (n-1)

for i in range(n-1):
	for j in range(i+1, n):
		dist = min(j-i, abs(x-1-i) + 1 + abs(j-y+1))
		result[dist-1] += 1

for ans in result:
	print(ans)


# TLE

# import queue
	
# q = queue.Queue()
# n, x, y = [int(i) for i in input().split()]
# result = [0] * (n-1)

# for p in range(n):
# 	dist_list = [111111] * n
# 	dist = 0
# 	q.put(p)
# 	dist_list[p] = dist 
# 	while not q.empty():
# 		p = q.get()
# 		dist = dist_list[p]
# 		if p+1 < n: 
# 			if dist_list[p+1] > dist:
# 				dist_list[p+1] = dist
# 				q.put(p+1)
# 		if p-1 < n: 
# 			if dist_list[p-1] > dist:
# 				dist_list[p-1] = dist
# 				q.put(p-1)
# 		if p == (x-1): 
# 			if dist_list[y-1] > dist:
# 				dist_list[y-1] = dist
# 				q.put(y-1)
# 		if p == (y-1): 
# 			if dist_list[x-1] > dist:
# 				dist_list[x-1] = dist
# 				q.put(x-1)

# 	for i in dist_list:
# 		if i != 0:
# 			result[i-1] += 1

# for ans in result:
# 	print(ans//2)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

from collections import deque

N = int(input())
a = [int(y) for y in input().split()]
a.sort()

q = deque()
for i in range(N):
    q.append(a[i])

cnt = 0

while N > 0:
    flag = True
    res = q.popleft()

    for i in range(N-1):
        now = q.popleft()
        if now == res and flag:
            cnt -= 1
            flag = False
        if now % res != 0:
            q.append(now)
    
    N = len(q)
    cnt += 1

print(cnt)

### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()]

max_a = max(a)
flag = [True for i in range(max_a+1)]

dup = set()
for i in range(n):
    if a[i] in dup:
        flag[a[i]] = False
    else:
        dup.add(a[i])
    for j in range(2*a[i], max_a+1, a[i]):
        flag[j] = False

ans = 0
for i in a:
    ans += flag[i]
print(ans)