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

li = input().split()
n = int(li[0])
m = int(li[1])
# IDカードn枚，　ゲートm個
l_r = []
# i番目のゲートはl~rのIDカードを持っていれば通過できる
for i in range(m):
    l_r.append(input().split())
answer = 0
for i in range(n):
    for lr in l_r:
        l = int(lr[0])
        r = int(lr[1])
        if l <= i + 1 and i + 1 <= r:
            continue
        else:
            break
    else:
        answer += 1
print(answer)

### FIXED CODE ###

li = input().split()
n = int(li[0])
m = int(li[1])
# IDカードn枚，　ゲートm個
# i番目のゲートはl~rのIDカードを持っていれば通過できる
l_r = [input().split() for i in range(m)]
l_r.sort(key=lambda x:int(x[0]))
l_max = int(l_r[-1][0])
l_r.sort(key=lambda x:int(x[1]))
r_min = int(l_r[0][1])
answer = 0
# for i in range(n):
#     if l_max <= i + 1 and i + 1 <= r_min:
#         answer += 1
diff = r_min - l_max + 1
if diff > 0:
    print(diff)
else:
    print(0)
### BUGGY CODE ###


def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


N=int(input())

S=[]
S_count=dict()
for n in range(N):
    s=input()
    s=''.join(sorted(s))
    if s in S:
        S_count[s]+=1
    else:
        S_count[s]=1
    S.append(s)

key=list(set(S))

total=0

for k in key:
    t=S_count[k]
    if t>=2:
        total+=cmb(t,2)

print(total)

### FIXED CODE ###


N=int(input())
S=[]
total=0

for s in range(N):
    tmp=input()
    S.append("".join(sorted(tmp)))

S=sorted(S)
S_key=list(set(S))
count=[0]*len(S_key)
S_dict=dict(zip(S_key,count))


for s in S:
    total+=S_dict[s]
    S_dict[s]+=1

print(total)
### BUGGY CODE ###

from collections import Counter

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

for i in range(1000):
    s = str(i).zfill(3)
    for i in range(N):
        if S[i]==s[0]:
            p = i
            break
    else:
        continue
    for i in range(p+1, N):
        if S[i]==s[1]:
            p = i
            break
    else:
        continue

    for i in range(p+1, N):
        if S[i]==s[2]:
            p = i
            break
    else:
        continue
    
    ans += 1

print(ans)


### FIXED CODE ###

n = int(input())
s = input()
ans = 0

for i in range(1000):
    t = str(i).zfill(3)
    isExists = [False]*3
    pos = 0
    for (p,j) in enumerate(t):
        while pos<n:
            if s[pos]==j:
                pos += 1
                isExists[p] = True
                break
            pos += 1
    if all(isExists):
        ans += 1

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

A,B,C,N= list(map(int,input().split()))
ans=0
for i in range(0,N//A+1):
   for j in range(0,N//B+1):
      if (N-i*A-j*B)%C==0 and (N-i*A-j*B)>-1:
         ans+=1
print(ans)

### FIXED CODE ###

A,B,C,N= list(map(int,input().split()))
ans=0
for i in range(0,N//A+1):
   for j in range(0,(N-i*A)//B+1):
      if (N-i*A-j*B)%C==0:
         ans+=1
print(ans)
### BUGGY CODE ###

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

cnt_a=0
cnt_b=0

for i in range(n-1):
    for j in range(i+1, n):
        if a[i] == a[j]:
            cnt_a += 1

for i in range(n):
    cnt_b=0
    for j in range(n):
        if i!=j and a[i]==a[j]:
            cnt_b+=1
    print(cnt_a-cnt_b)
    

### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))

import collections
 
c = collections.Counter(l)
ans = 0

for i in c.values():
    ans += i * (i - 1) // 2
    
for i in l:
    print(ans - c[i] + 1)
### BUGGY CODE ###

linha1 = input()
n, k = [int(item) for item in linha1.split()]
linha2 = input()
alturas = [int(item) for item in linha2.split()]
matriz = [[abs(alturas[0] - alturas[1])]]
#matriz[0].append(abs(alturas[0] - alturas[1]))
if n > 2:
    for i in range(1,n-1):
        matriz.append([])
        for j in range(0,min(k, i+1, n-1)):
            if i-j == 0:
                custo_atual = abs(alturas[i+1] - alturas[0])
            else:
                custo_atual = abs(alturas[i+1] - alturas[i-j]) + min(matriz[i-j-1])
            matriz[i].append(custo_atual)
print(min(matriz[-1]))

### FIXED CODE ###

from sys import stdin
n, k = [int(i) for i in stdin.readline().split(' ')]
h = [int(i) for i in stdin.readline().split(' ')]

minCosts = [0, abs(h[1]-h[0])]
for i in range(2, len(h)):
    minCosts.append(min([abs(h[i]-h[i-j])+minCosts[i-j] for j in range(1, min(i, k)+1)]))

print(minCosts[-1])
### BUGGY CODE ###

def gcd(a,b,c):
    #1
    seq  = [a,b,c]
    seq.sort()
    while b > 0:
        r = c%b
        c = b
        b = r
    #2
    seq_2 = [a,c]
    seq_2.sort()
    while a > 0:
        r = c%a
        c = a
        a = r
    return c
    

k = int(input())
ans=[]

for i in range(1,k+1):
    for j in range(1,k+1):
        for k in range(1,k+1):
            p = gcd(i,j,k)
            ans.append(p)

print(sum(ans))


### FIXED CODE ###

def gcd(a,b,c):
    #1
    seq  = [a,b,c]
    seq.sort()
    while b > 0:
        r = c%b
        c = b
        b = r
    #2
    seq_2 = [a,c]
    seq_2.sort()
    while a > 0:
        r = c%a
        c = a
        a = r
    return c

from functools import reduce

k = int(input())
ans = 0

for i in range(1,k+1):
    for j in range(i,k+1):
        for k in range(j,k+1):
            t = len(set([i,j,k]))
            
            if t == 1:
                ans += gcd(i,j,k)
                
            elif t == 2:
                ans += gcd(i,j,k)*3
            
            elif t == 3:
                ans += gcd(i,j,k)*6
    

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

from bisect import insort_left, bisect_left
n, m = map(int, input().split())
d = [[] for _ in range(n + 1)]
m = [tuple(map(int, input().split())) for _ in range(m)]

for p, y in m:
    insort_left(d[p], y)

for p, y in m:
    print('{:06}{:06}'.format(p, bisect_left(d[p], y)+1))


### FIXED CODE ###

from bisect import bisect_left
from collections import defaultdict
n, m = map(int, input().split())
m = [tuple(map(int, input().split())) for _ in range(m)]

d = defaultdict(list)
for p, y in sorted(m):
    d[p] += [y]


for p, y in m:
    i = bisect_left(d[p], y)
    print('{:06}{:06}'.format(p, i+1))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(500000)

def get_cost(arr, n, dp):
  if dp[n] != 0:
    return dp[n]
  if n == 1:
    dp[1] = abs(arr[1] - arr[0])
    return dp[1]
  elif n == 0:
    dp[0] = 0
    return dp[0]
  else:
    dp[n] = min(
      abs(arr[n] - arr[n-1]) + get_cost(arr, n-1, dp),
      abs(arr[n] - arr[n-2]) + get_cost(arr, n-2, dp)
    )
    return dp[n]


N = int(input())
arr = [int(num) for num in input().split()]
dp_arr = [0]*N
print(get_cost(arr, N-1, dp_arr))


### FIXED CODE ###

import sys
sys.setrecursionlimit(500000)

def get_cost(arr, n, dp):
  if dp[n] != float('inf'):
    return dp[n]
  if n == 1:
    dp[1] = abs(arr[1] - arr[0])
    return dp[1]
  elif n == 0:
    dp[0] = 0
    return dp[0]
  else:
    dp[n] = min(
      abs(arr[n] - arr[n-1]) + get_cost(arr, n-1, dp),
      abs(arr[n] - arr[n-2]) + get_cost(arr, n-2, dp)
    )
    return dp[n]


N = int(input())
arr = [int(num) for num in input().split()]
dp_arr = [float('inf')]*N
print(get_cost(arr, N-1, dp_arr))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
#グローバル変数
pn_list = [2,3]

def next_pn(pn):
    npn = pn + 2
    pn_flg = 0
    while pn_flg == 0:
        for i in pn_list:
            if npn % i == 0:
                break
            if (i ** 2) > npn:
                pn_flg = 1
                break
        if pn_flg == 1:
            break # 素数が見つかったらbreak
        else:
            npn += 2
    pn_list.append(npn)
    return npn

def check_a(n,a):
    res = "ok"
    for i in range(n):
        if a[i] > 1:
            res = "notyet"
    return res

# 整数の入力
n = int(input())
s = input()
a = [int(x) for x in s.split()]
aa = [int(x) for x in s.split()]

#素数作成
sqr_max_a = int((1.0 * 10**6) ** 0.5) + 1
#sqr_max_a = int(1.0 * 10**6)
pn = 3
while pn < sqr_max_a:
    pn = next_pn(pn)

# a を素因数分解する
lcm = int(1)
for i in pn_list:
    wareta = 1
    while wareta == 1:
        wareta = 0
        for j in range(n):
            if a[j] % i == 0:
                a[j] = a[j] // i
                wareta = 1
        if wareta == 1:
            lcm = lcm * i
    if check_a(n,a) == "ok":
        break

pn_lcm = []
for i in a:
    if i > 1:
        if i not in pn_lcm:
            pn_lcm.append(i)
            lcm = lcm * i

min_bsum = int(0)
for i in aa:
    min_bsum = min_bsum + lcm // i

print(min_bsum % (10**9+7))


### FIXED CODE ###

# -*- coding: utf-8 -*-
#グローバル変数
pn_list = [2,3]

def next_pn(pn):
    npn = pn + 2
    pn_flg = 0
    while pn_flg == 0:
        for i in pn_list:
            if npn % i == 0:
                break
            if (i ** 2) > npn:
                pn_flg = 1
                break
        if pn_flg == 1:
            break # 素数が見つかったらbreak
        else:
            npn += 2
    pn_list.append(npn)
    return npn

# 整数の入力
n = int(input())
s = input()
a = [int(x) for x in s.split()]
aa = [int(x) for x in s.split()]

#素数作成
sqr_max_a = int((1.0 * 10**6) ** 0.5) + 1
#sqr_max_a = int(1.0 * 10**6)
pn = 3
while pn < sqr_max_a:
    pn = next_pn(pn)

# a を素因数分解する
lcm = int(1)
for i in pn_list:
    wareta = 1
    while wareta == 1:
        wareta = 0
        for j in range(n):
            if a[j] % i == 0:
                a[j] = a[j] // i
                wareta = 1
        if wareta == 1:
            lcm = lcm * i
pn_lcm = []
for i in a:
    if i > 1:
        if i not in pn_lcm:
            pn_lcm.append(i)
            lcm = lcm * i

min_bsum = int(0)
for i in aa:
    min_bsum = min_bsum + lcm // i

print(min_bsum % (10**9+7))
### BUGGY CODE ###

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

tmp = 1
for i in range(k):
    tmp *= a[i]

for i in range(k,n):
    now = (tmp/a[i-k])*a[i] 
    if now > tmp:
        print("Yes")
    else:
        print("No")
    tmp = now



### FIXED CODE ###

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

for i in range(k,n):
    if a[i-k] < a[i]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

import math
from math import floor
A,B,N = map(int,input().split())
maxi = 0
Npower = 0
diff = 0
S = N
while S/10 >= 1:
    Npower += 1
    S /=10
if Npower >= 7:
    for i in range(0,10**6+10**5):
        maxi = max(floor((A*i)/B)-A*floor(i/B),maxi)
    for i in range(N-10**7,N+1):
        maxi = max(floor((A*i)/B)-A*floor(i/B),maxi)
else:
    for i in range(0,N+1):
        maxi = max(floor((A*i)/B)-A*floor(i/B),maxi)
print(max(maxi,0))


### FIXED CODE ###

import math
from math import floor
A,B,N = map(int,input().split())
def f(x):
  return floor(A*x/B) - A*floor(x/B)
print(f(min(B-1,N)))
### BUGGY CODE ###

# coding: utf-8
# Your code here!

n=int(input())
ans=0
for i in range(n-1):
    ans+=i+1
    
print(ans)

### FIXED CODE ###

# coding: utf-8
# Your code here!

n=int(input())

ans=(n*(n-1))//2
print(ans)
### BUGGY CODE ###

from math import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)

k = int(input())
ans = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        for l in range(1, k + 1):
            ans += gcd_list([i, j, l])
print(ans)

### FIXED CODE ###

from math import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)

k = int(input())
ans = 0
rev = 0
for i in range(1, k + 1):
    for j in range(i, k + 1):
        tmp = gcd(i, j)
        for l in range(j, k + 1):
            if i == j and j == l:
                ans += i
            elif i == j or j == l or l == i:
                ans += gcd(tmp, l) * 3
            else:
                ans += gcd(tmp, l) * 6
print(ans)
### BUGGY CODE ###

MAX = 10**9

n, k = map(int, input().split())
cost = list(map(int, input().split()))
dp = [MAX] * (n)
dp[0] = 0

for i in range(1, n):
    for j in range(max(0, i-k), i+1):
                dp[i] = min(dp[i] ,dp[j] + abs(cost[i] - cost[j]))

print(dp[-1])


### FIXED CODE ###

#!/usr/bin/env pypy

import sys
inp = sys.stdin.readline
out = print
MAX = 10**9
 
n, k = map(int, inp().split())
cost = list(map(int, inp().split()))
dp = [MAX] * (n)
dp[0] = 0
 
for i in range(1, n):
    dp[i] = min(dp[j] + abs(cost[i] - cost[j]) for j in range(max(0, i - k), i))
 
out(dp[-1])
### BUGGY CODE ###

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

for k in range(N):
  for j in range(k):
    for i in range(j):
      if S[i] != S[j] and S[j] != S[k] and S[k] != S[i] and j-i != k-j:
        l += 1
      else:
        pass

print(l)

### FIXED CODE ###

import re

N = int(input())
S = input()

R = re.findall("R", S)
G = re.findall("G", S)
B = re.findall("B", S)

c = 0
for i in range(N-2):
  for d in range((N-1-i)//2):
    if S[i] != S[i+d+1] and S[i+d+1] != S[i+2*d+2] and S[i+2*d+2] != S[i]:
      c += 1

print(len(R)*len(G)*len(B)-c)
### BUGGY CODE ###

K, N = map(int, input().split())
houses = list(map(int, input().split()))
# syaku_houses = []
# for i, num in enumerate(houses):
#     if i == 0:
#         syaku_houses.append(num)
#     else:
#         syaku_houses.append(num - houses[i - 1])
# print(syaku_houses)

# min_costs = []
# for house in syaku_houses:

# 右回りか左回りか？
reverse_houses = []
for i in range(N - 1):
    reverse_houses.insert(0, -1 * (K - houses[N - 1 - i]))
reverse_houses.reverse()
for house in reverse_houses:
    houses.insert(0, house)

min_costs = []
for i in range(N):
    min_costs.append(houses[N - 1 + i] - houses[i])
print(min(min_costs))


### FIXED CODE ###

K, N = map(int, input().split())
houses = list(map(int, input().split()))
# syaku_houses = []
# for i, num in enumerate(houses):
#     if i == 0:
#         syaku_houses.append(num)
#     else:
#         syaku_houses.append(num - houses[i - 1])
# print(syaku_houses)

# min_costs = []
# for house in syaku_houses:

# 右回りか左回りか？
for i in range(N - 1):
    houses.append(K + houses[i])

min_costs = []
for i in range(N):
    min_costs.append(houses[N - 1 + i] - houses[i])
print(min(min_costs))
### BUGGY CODE ###

n, k = [int(_) for _ in input().split()]
s = []
for i in range(k):
    l, r = [int(_) for _ in input().split()]
    for j in range(l, r+1):
        s.append(j)
# print(s)
dp = [0 for i in range(n)]
dp[0] = 1
# print(dp)
for i in range(n):
    for j in s:
        if i-j >= 0:
            dp[i] += dp[i-j]
    # print(dp)
print(dp[-1]%998244353)

### FIXED CODE ###

n, k = [int(_) for _ in input().split()]
s = []
for i in range(k):
    s.append([int(_) for _ in input().split()])
# print(s)
dp = [0 for i in range(n)]
dp[0] = 1
dp_s = [0 for i in range(n+1)]
dp_s[1] = 1
# print(dp)
# print(dp_s)
# print('*****************')
for i in range(1, n):
    for j in range(len(s)):
        r, l = s[j]
        if i-r >= 0:
            if i-l >= 0:
                dp[i] += dp_s[i-r+1] - dp_s[i-l]
            else:
                dp[i] += dp_s[i-r+1] - dp_s[0]
    dp[i] = dp[i] % 998244353
    # print(dp)
    dp_s[i+1] += dp_s[i] + dp[i]
    dp_s[i+1] = dp_s[i+1] % 998244353
    # print(dp_s)
    # print('*****************')
print(dp[-1])
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(1,1+n):
  c=a.count(i)
  ans+=(c*(c-1))//2
for k in range(n):
  c=a.count(a[k])
  print(ans-c+1)

### FIXED CODE ###

N = int(input())
A = [int(x) for x in input().split()]
l = [0]*N
ans = 0
for a in A:
    l[a-1] += 1
for j in l:
    ans += int(j*(j-1)/2)
for k in range(N):
    print(ans - l[A[k]-1] + 1)
### BUGGY CODE ###

s = input()
n = len(s)
ans = [0] * n
for i in range(n):
    t = 0
    p = i
    c = s[p]
    while c == s[p]:
        p += 1 if c == 'R' else -1
        t += 1
    if t % 2 == 1:
        p -= 1 if c == 'R' else -1
    ans[p] += 1
print(' '.join([str(x) for x in ans]))

### FIXED CODE ###

import math
s = input()
n = len(s)
ans = [0] * n
i = 0
while i < n:
    r = 0
    while s[i] == 'R':
        r += 1
        i += 1
    ans[i-1] += math.ceil(r / 2)
    ans[i] += math.floor(r / 2)
    l = 0
    while i < n and s[i] == 'L':
        l += 1
        i += 1
    ans[i-l-1] += math.floor(l / 2)
    ans[i-l] += math.ceil(l / 2)
print(' '.join([str(x) for x in ans]))
### BUGGY CODE ###

S = input()

mods = []
cnt = 0
for i in range(len(S)):
    mod = int(S[i:]) % 2019
    if mod == 0:
        cnt += 1
    else:
        cnt += mods.count(mod)
        mods.append(mod)

print(cnt)

### FIXED CODE ###

s = list(input())
mods = [0]*(len(s))
countRemainder = [0] * 2019
cnt = 0


m = 1
mod = 0
for i in range(len(s)):
    mod += int(s[len(s) - i - 1]) * m

    mod %= 2019
    m *= 10
    m %= 2019

    countRemainder[mod] += 1

countRemainder[0] += 1

for i in range(2019):
    cnt += int(countRemainder[i] * (countRemainder[i] - 1) / 2)

print(cnt)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
import collections
for i in range(n):
    A = a[0:i]+a[i+1:n]
    c = collections.Counter(A)
    s = 0
    for j in c.keys():
        s += c[j]*(c[j]-1)//2
    print(s)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
import collections
C = collections.Counter(a)
S = 0
for i in C.keys():
    S += C[i]*(C[i]-1)//2

for i in range(n):
    A = a[i]
    print(S-C[A]+1)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
ans = 0
flag = True
while True:
    tmp = 0
    for j in range(n):
        if not a[j]:
            tmp += 1
            continue
        c = a[j][0]
        if c == "-":
            continue
        if j + 1 == a[c-1][0]:
            a[j][0] = "-"
            a[c-1][0] = "-"
    if tmp == n:
        print(ans)
        break
    for j in range(n):
        if a[j]:
            if a[j][0] == "-":
                a[j] = a[j][1:]
                flag = False
    if flag:
        print(-1)
        break
    else:
        ans += 1


### FIXED CODE ###

import sys
input = sys.stdin.readline
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
ans = 0
r = set(list(range(n)))
N = n*(n-1) // 2 + 1
for _ in range(N):
    if not r:
        print(_)
        break
    ne = set()
    flag = True
    for j in r:
        if not a[j]:
            continue
        c = a[j][0]
        if c == "-":
            continue
        if j + 1 == a[c-1][0]:
            a[j][0] = "-"
            a[c-1][0] = "-"
            ne.add(j)
            ne.add(c-1)
    for j in list(ne):
        if a[j]:
            if a[j][0] == "-":
                a[j].pop(0)
                flag = False
                if not a[j]:
                    ne.remove(j)
    if flag:
        print(-1)
        break
    else:
        r = ne
### BUGGY CODE ###

k,s = list(map(int,input().split()))

count=0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x+y+z==s:
                count+=1

print(count)

### FIXED CODE ###

k,s = list(map(int,input().split()))

count=0
for x in range(k+1):
    for y in range(k+1):
        if 0<=s-x-y and s-x-y<=k:
            count+=1

print(count)
### BUGGY CODE ###

n = int(input())
a = [int(x) for x in input().split()]
ans = 0

for i in range(n-1):
  for j in range(i+1,n):
    ans += a[i]*a[j]
print(ans%(10**9+7))

### FIXED CODE ###

n = int(input())
a = [int(x) for x in input().split()]
sum = 0
ans = 0

for e in a:
  sum += e
  
for e in a:
  sum -= e
  ans += e*sum

print(ans%(10**9+7))
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
aa=0
for i in range(n):
    if a.count(a[i])!=1:
        print('NO')
        aa+=1
        break
if aa==0:
    print('YES')

### FIXED CODE ###

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

if len(a)==len(s):
    print('YES')
else:
    print('NO')
### BUGGY CODE ###

def solve(sup,rest,digit,used1,used2):
    if digit==0:
        if rest==0:
            return 1
        else:
            return 0
    sum=0
    for i in range(1,sup+1):
        if i!=used1 and i!=used2:
            if used1==0:
                sum+=solve(sup,rest-i,digit-1,i,used2)
            elif used2==0:
                sum+=solve(sup,rest-i,digit-1,used1,i)
            else:
                sum+=solve(sup,rest-i,digit-1,used1,used2)
    return sum

N=[]
X=[]
while True:
    n,x=map(int,raw_input().split())
    if (n,x)==(0,0):
        break
    N.append(n)
    X.append(x)
for i in range(len(N)):
    print('%d'%(solve(N[i],X[i],3,0,0)/6))

### FIXED CODE ###

def solve(sup,rest,digit,used1,used2):
    if rest<0:
        return 0
    if digit==0:
        if rest==0:
            return 1
        else:
            return 0
    sum=0
    for i in range(1,sup+1):
        if i!=used1 and i!=used2:
            if used1==0:
                sum+=solve(sup,rest-i,digit-1,i,used2)
            elif used2==0:
                sum+=solve(sup,rest-i,digit-1,used1,i)
            else:
                sum+=solve(sup,rest-i,digit-1,used1,used2)
    return sum

N=[]
X=[]
while True:
    n,x=map(int,raw_input().split())
    if (n,x)==(0,0):
        break
    N.append(n)
    X.append(x)
for i in range(len(N)):
    print('%d'%(solve(N[i],X[i],3,0,0)/6))
### BUGGY CODE ###

##WA 和がSになる組み合わせを列挙しようとしたけど無理だった。
ma = lambda :map(int,input().split())
ni = lambda:int(input())
import collections
import math
import itertools
gcd = math.gcd
mod = 998244353
n,s = ma()
A = list(ma())
dp = [[0]*(s+1) for i in range(n+1)]#dp[i][j]はi番目までの要素を用いてjになるような場合の数
dp[0][0] = 1
for i in range(n):
    a = A[i]
    for j in range(s+1):
        dp[i+1][j] =(dp[i][j]*2)%mod
        if a<=j:
            dp[i+1][j] = (dp[i][j-a] +dp[i+1][j]) %mod

print(dp[n][s])
#print(dp)


### FIXED CODE ###

##WA 和がSになる組み合わせを列挙しようとしたけど無理だった。
ma = lambda :map(int,input().split())
ni = lambda:int(input())
import collections
import math
import itertools
gcd = math.gcd
mod = 998244353
n,s = ma()
A = list(ma())
dp = [[0]*(s+1) for i in range(n+1)]#dp[i][j]はi番目までの要素を用いてjになるような場合の数
dp[0][0] = 1
for i in range(n):
    a = A[i]
    for j in range(s+1):
        dp[i+1][j] =(dp[i][j]*2)%mod
        if a<=j:
            dp[i+1][j] = (dp[i][j-a] +dp[i+1][j]) %mod

print(dp[n][s])
#print(dp)
### BUGGY CODE ###

n = int(input())

p = list(map(int,input().split()))

s = [0]*n

for i in range(1,n+1):
    a = min(p[:i])
    
    s[i-1] = a

cnt = 0
for i in range(n):
    if p[i] == s[i]:
        cnt += 1
        
print(cnt)

### FIXED CODE ###

n=int(input())
p=list(map(int,input().split()))
ans=0
a=p[0]
for i in range(n):
    if p[i] <= a:
        ans+=1
    
    a=min(a,p[i])    


print(ans)