CodeEff/ECCO huggingface dataset:
# Original solution
n, m = list(map(int, input().split()))
tree = [[] for _i in range(m+1)]
k = []
for i in range(n):
    x = list(map(int, input().split()))
    for j in x[1:]:
        tree[j].append(i)
    k.append(x[1:])

visit = [0 for _ in range(n)]
from collections import deque
q = deque([0])
while q:
    p = q.pop()
    if visit[p]==1:
        continue
    visit[p] = 1
    for i in k[p]:
        for j in tree[i]:
            if visit[j]==0:
                q.appendleft(j)
if sum(visit)==n:
    print("YES")
else:
    print("NO")

# Optimized solution
n, m = list(map(int, input().split()))
tree = [[] for _i in range(m+n+1)]
for i in range(n):
    x = list(map(int, input().split()))
    tree[i].extend([i+n for i in x[1:]])
    for j in x[1:]:
        tree[j+n].append(i)

from collections import deque
q = deque([1])
visit = [0 for _i in range(m+n+2)]
visit[1] = 1
while q:
    p = q.pop()
    for j in tree[p]:
        if visit[j]==0:
            visit[j] = 1
            q.appendleft(j)
if sum(visit[:n]) == n:
    print("YES")
else:
    print("NO")
# Original solution
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()

class UnionFind(object):
    def __init__(self,n):
        self.__par=list(range(n))
        self.__rank=[0]*n
        self.__size=[1]*n

    def root(self,k):
        if(self.__par[k]==k): return k
        self.__par[k]=self.root(self.__par[k])
        return self.__par[k]

    def unite(self,i,j):
        i=self.root(i); j=self.root(j)
        par=self.__par; rank=self.__rank; size=self.__size
        if(i==j): return False
        if(rank[i]>rank[j]):
            par[j]=i
            size[i]+=size[j]
        else:
            par[i]=j
            size[j]+=size[i]
            if(rank[i]==rank[j]): rank[j]+=1
        return True

    def is_same(self,i,j):
        return self.root(i)==self.root(j)

    def size(self,k):
        return self.__size[self.root(k)]

def resolve():
    n,m=list(map(int,input().split()))
    uf=UnionFind(m)
    S=set()
    for _ in range(n):
        L=list(map(int,input().split()))[::-1]
        k=L.pop()
        for i in range(k):
            S.add(L[i]-1)
            if(i+1<k):
                uf.unite(L[i]-1,L[i+1]-1)

    print(("YES" if(max(uf.size(i) for i in range(m))==len(S)) else "NO"))
resolve()

# Optimized solution
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n,m=list(map(int,input().split()))
    # n,m の bipartite graph
    E=[[] for _ in range(n+m)]
    for i in range(n):
        L=list([int(x)-1 for x in input().split()])[::-1]
        L.pop()
        for l in L:
            E[i].append(n+l)
            E[n+l].append(i)

    # 0,...,n-1 が連結かどうかを見る
    used=[0]*(n+m)
    used[0]=1
    Q=[0]
    while(Q):
        v=Q.pop()
        for nv in E[v]:
            if(used[nv]): continue
            used[nv]=1
            Q.append(nv)

    print(("YES" if(min(used[:n])==1) else "NO"))
resolve()
# Original solution
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)


n, m = list(map(int, input().split()))
uf = UnionFind(n + m)

for i in range(n):
    k, *L = list(map(int, input().split()))
    for l in L:
        uf.union(l - 1, m + i)

for i in range(n - 1):
    if not uf.same(m + i, m + i + 1):
        print("NO")
        break
else:
    print("YES")


# Optimized solution
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    def dfs(v):
        for u in edge[v]:
            if visited[u]:
                continue
            else:
                visited[u] = True
                dfs(u)

    n, m = list(map(int, input().split()))
    edge = [[] for _ in range(n + m)]
    for i in range(n):
        _, *L = list(map(int, input().split()))
        for l in L:
            edge[i].append(n + l - 1)
            edge[n + l - 1].append(i)

    visited = [False] * (n + m)
    dfs(0)
    for i in range(n):
        if not visited[i]:
            print("NO")
            break
    else:
        print("YES")


if __name__ == '__main__':
    resolve()
# Original solution
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

N, M = list(map(int, input().split()))
KL = [[int(i) for i in input().split()] for _ in range(N)]

lang = [[] for _ in range(M)]
for i in range(N) :
    for j in KL[i][1:] :
        lang[j-1].append(i)
        
visited = [False] * N
visited[0] = True
q = [0]
while q :
    cur = q.pop()
    for l in KL[cur][1:] :
        for m in lang[l-1] :
            if not visited[m] :
                q.append(m)
                visited[m] = True
                
if sum(visited) == N :
    print('YES')
else :
    print('NO')

# Optimized solution
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

N, M = list(map(int, input().split()))
v = [[] for _ in range(N+M)]
for i in range(N) :
    K, *L = list(map(int, input().split()))
    for l in L :
        v[N+l-1].append(i)
        v[i].append(N+l-1)

visited = [False] * (N + M)
visited[0] = True
q = [0]

while q :
    cur = q.pop()
    for nex in v[cur] :
        if not visited[nex] :
            q.append(nex)
            visited[nex] = True

if sum(visited[:N]) == N :
    print('YES')
else :
    print('NO')
# Original solution
class UnionFind:
    def __init__(self, size):
        self.data = [-1 for _ in range(size)]
    def find(self, x):
        if self.data[x] < 0:
            return x
        else:
            self.data[x] = self.find(self.data[x])
            return self.data[x]
    def union(self, x, y):
        x, y = self.find(x), self.find(y)
        if x != y:
            if self.data[y] < self.data[x]:
                x, y = y, x
            self.data[x] += self.data[y]
            self.data[y] = x
        return (x != y)
    def same(self, x, y):
        return (self.find(x) == self.find(y))
    def size(self, x):
        return -self.data[self.find(x)]

N, M = list(map(int, input().split()))
uf = UnionFind(N + M + 1)
for i in range(1, N + 1):
    K, *L = list(map(int, input().split()))
    for l in L:
        uf.union(i, l + N)

if all(uf.same(i, N) for i in range(1, N)):
    print("YES")
else:
    print("NO")


# Optimized solution
class UnionFind:
	def __init__(self, size):
		self.data = [-1] * size
	def find(self, x):
		if self.data[x] < 0:
			return x
		else:
			self.data[x] = self.find(self.data[x])
			return self.data[x]
	def union(self, x, y):
		x, y = self.find(x), self.find(y)
		if x != y:
			if self.data[y] < self.data[x]:
				x, y = y, x
			self.data[x] += self.data[y]
			self.data[y] = x
		return (x != y)
	def same(self, x, y):
		return (self.find(x) == self.find(y))

N, M = list(map(int, input().split()))
uf = UnionFind(N + M + 1)
for i in range(1, N + 1):
	K, *L = list(map(int, input().split()))
	for l in L:
		uf.union(i, l + N)

if all(uf.same(i, N) for i in range(1, N)):
	print("YES")
else:
	print("NO")
# Original solution
class UnionFind:
	def __init__(self, size):
		self.data = [-1] * size
	def find(self, x):
		if self.data[x] < 0:
			return x
		else:
			self.data[x] = self.find(self.data[x])
			return self.data[x]
	def union(self, x, y):
		x, y = self.find(x), self.find(y)
		if x != y:
			if self.data[y] < self.data[x]:
				x, y = y, x
			self.data[x] += self.data[y]
			self.data[y] = x
		return (x != y)
	def same(self, x, y):
		return (self.find(x) == self.find(y))

N, M = list(map(int, input().split()))
uf = UnionFind(N + M + 1)
for i in range(1, N + 1):
	K, *L = list(map(int, input().split()))
	for l in L:
		uf.union(i, l + N)

if all(uf.same(i, N) for i in range(1, N)):
	print("YES")
else:
	print("NO")

# Optimized solution
class UnionFind:
    def __init__(self, size):
        self.data = [-1] * size

    def find(self, x):
        if self.data[x] < 0:
            return x
        else:
            self.data[x] = self.find(self.data[x])
            return self.data[x]

    def union(self, x, y):
        x, y = self.find(x), self.find(y)
        if x != y:
            if self.data[y] < self.data[x]:
                x, y = y, x
            self.data[x] += self.data[y]
            self.data[y] = x
        return (x != y)

    def same(self, x, y):
        return (self.find(x) == self.find(y))

    def size(self, x):
        return -self.data[self.find(x)]


N, M = list(map(int, input().split()))
uf = UnionFind(N + M + 1)
used = [False] * (M + 1)
for i in range(1, N + 1):
    K, *L = list(map(int, input().split()))
    for l in L:
        uf.union(i, l + N)
        used[l] = True

if uf.size(1) - sum(used) == N:
    print("YES")
else:
    print("NO")
# Original solution
class UnionFind:
    def __init__(self, size):
        self.data = [-1] * size

    def find(self, x):
        if self.data[x] < 0:
            return x
        else:
            self.data[x] = self.find(self.data[x])
            return self.data[x]

    def union(self, x, y):
        x, y = self.find(x), self.find(y)
        if x != y:
            if self.data[y] < self.data[x]:
                x, y = y, x
            self.data[x] += self.data[y]
            self.data[y] = x
        return (x != y)

    def same(self, x, y):
        return (self.find(x) == self.find(y))

    def size(self, x):
        return -self.data[self.find(x)]


N, M = list(map(int, input().split()))
uf = UnionFind(N + M + 1)
used = set()
for i in range(1, N + 1):
    K, *L = list(map(int, input().split()))
    for l in L:
        uf.union(i, l + N)
        used.add(l)

if uf.size(1) - len(used) == N:
    print("YES")
else:
    print("NO")


# Optimized solution
class UnionFind:
    def __init__(self, size):
        self.data = [-1] * size

    def find(self, x):
        if self.data[x] < 0:
            return x
        else:
            self.data[x] = self.find(self.data[x])
            return self.data[x]

    def union(self, x, y):
        x, y = self.find(x), self.find(y)
        if x != y:
            if self.data[y] < self.data[x]:
                x, y = y, x
            self.data[x] += self.data[y]
            self.data[y] = x
        return (x != y)

    def same(self, x, y):
        return (self.find(x) == self.find(y))

    def size(self, x):
        return -self.data[self.find(x)]


N, M = list(map(int, input().split()))
uf = UnionFind(M + 1)
used = set()
for _ in range(N):
    K, *L = list(map(int, input().split()))
    for l in L:
        uf.union(L[0], l)
    used.update(L)

if uf.size(used.pop()) == 1 + len(used):
    print("YES")
else:
    print("NO")
# Original solution
n,m=map(int,input().split())
class UnionFind:
    #def   -> foo=UnionFind(n,1)  <- 1-based index, default is 0
    #method -> foo.hoge(huga)
    __slots__ = ["_size", "_first_idx", "_parents"]
    def __init__(self, size: int, first_index: int = 0) -> None:
        self._size = size
        self._first_idx = first_index
        self._parents = [-1] * (size + first_index)
    def find(self, x: int) -> int:
        if self._parents[x] < 0:
            return x
        self._parents[x] = self.find(self._parents[x])
        return self._parents[x]
    def same(self, x: int, y: int) -> bool:
        return self.find(x) == self.find(y)
    def unite(self, x: int, y: int) -> bool:
        x, y = self.find(x), self.find(y)
        if x == y:
            return False
        if self._parents[x] > self._parents[y]:
            x, y = y, x
        self._parents[x] += self._parents[y]
        self._parents[y] = x
        return True
    def size(self, x: int) -> int:
        return -self._parents[self.find(x)]
    def group_count(self) ->int:
        return sum(1 for i in  self._parents if i<0)
lanper=[-1]*m
uf=UnionFind(n)
for i in range(n):
    for j in list(map(int,input().split()))[1:]:
        if lanper[j-1]==-1:lanper[j-1]=i
        else:uf.unite(lanper[j-1],i)
print("YES") if uf.group_count()==1 else print("NO")


# Optimized solution
n,m=map(int,input().split())
class UnionFind:
    #def   -> foo=UnionFind(n,1)  <- 1-based index, default is 0
    #method -> foo.hoge(huga)
    __slots__ = ["_size", "_first_idx", "_parents"]
    def __init__(self, size: int, first_index: int = 0) -> None:
        self._size = size
        self._first_idx = first_index
        self._parents = [-1] * (size + first_index)
    def find(self, x: int) -> int:
        if self._parents[x] < 0:
            return x
        self._parents[x] = self.find(self._parents[x])
        return self._parents[x]
    def same(self, x: int, y: int) -> bool:
        return self.find(x) == self.find(y)
    def unite(self, x: int, y: int) -> bool:
        x, y = self.find(x), self.find(y)
        if x == y:
            return False
        if self._parents[x] > self._parents[y]:
            x, y = y, x
        self._parents[x] += self._parents[y]
        self._parents[y] = x
        return True
    def size(self, x: int) -> int:
        return -self._parents[self.find(x)]
    def group_count(self) ->int:
        return sum(1 for i in  self._parents if i<0)
lanper=[-1]*m
uf=UnionFind(n)
for i in range(n):
    for j in list(map(int,input().split()))[1:]:
        if lanper[j-1]==-1:lanper[j-1]=i
        else:uf.unite(lanper[j-1],i)
print("YES") if uf.size(0)==n else print("NO")
# Original solution
N,M = list(map(int,input().split()))
people = [None] * N
from collections import defaultdict
lang = defaultdict(set)

for i in range(N):
  people[i] = list(map(int,input().split()))[1:]
  for l in people[i]:
    lang[l].add(i)
    
# 0番の人からたどって全員に行けるか
stack = [0]
seen = [False for i in range(N)]

while stack:
  p = stack.pop()
  if seen[p]:
    continue
  seen[p] = True
  la = people[p] # その人が話せる言語リスト
  for l in la:
    lang[l].remove(p)
    for pe in lang[l]:
      stack.append(pe)
  
for s in seen:
  if not s:
    print("NO")
    break
else:
  print("YES")


# Optimized solution
# 人も言語もグラフの頂点と見なす
# ある人がある言語を話せる場合連結となる
# 頂点のキーは[言語 or 人][番号(人番号 or 言語番号)]
# 0:言語 1:人

N,M = list(map(int,input().split()))
from collections import defaultdict
E = [[],[]]
E[0] = [[] for i in range(M)]
E[1] = [[] for i in range(N)]

for i in range(N):
  langs = list(map(int,input().split()))[1:]
  for lang in langs:
    E[1][i].append((0,lang-1))
    E[0][lang-1].append((1,i))
    
# 任意の頂点からBFSして、全ての人の頂点が往訪済みになればOK
from collections import deque
q = deque([])
# 人で、0番目からスタート
q.append((1,0))
seen = [[],[]]
seen[0] = [False for i in range(M)]
seen[1] = [False for i in range(N)]

while q:
  kind,v = q.popleft()
  if seen[kind][v]:
    continue
  seen[kind][v] = True
  children = E[kind][v]
  for child in children:
    q.append([child[0],child[1]])
    
for s in seen[1]:
  if not s:
    print("NO")
    break
else:
  print("YES")
# Original solution
while 1:
    n,p = list(map(int,input().split()))
    if n==0:break
    man =  [0]*n
    ball,a = p,0
    while p not in man:
        if ball >0:ball,man[a%n] =ball-1, man[a%n]+1
        elif ball == 0:ball,man[a%n] = man[a%n],ball
        a+=1
    print((man.index(max(man))))            

# Optimized solution
while 1:
    n,p = list(map(int,input().split()))
    if n==0:break
    man =  [0]*n
    ball,a = p,0
    while 1:
        if ball >0:ball,man[a%n] =ball-1, man[a%n]+1
        elif ball == 0:ball,man[a%n] = man[a%n],ball
        a+=1
        if p in man:break
    print((man.index(max(man))))
# Original solution
while 1:
    n,p = list(map(int,input().split()))
    if n==0:break
    man =  [0]*n
    ball,a = p,0
    while 1:
        if ball >0:ball,man[a%n] =ball-1, man[a%n]+1
        elif ball == 0:ball,man[a%n] = man[a%n],ball
        a+=1
        if p in man:break
    print((man.index(max(man))))                 

# Optimized solution
while 1:
    n,p = list(map(int,input().split()))
    if n==0:break
    man =  [0]*n
    ball,a = p,0
    while 1:
        a%=n
        if ball >0:ball,man[a] =ball-1, man[a]+1
        elif ball == 0:ball,man[a] = man[a],ball
        a+=1
        if p in man:break
    print((man.index(max(man))))
# Original solution
while 1:
    n,p = list(map(int,input().split()))
    if n==0:break
    man =  [0]*n
    ball,a = p,0
    while 1:
        a%=n
        if ball >0:
            ball-=1
            man[a]+=1
        elif ball == 0:ball,man[a] = man[a],ball
        a+=1
        if p in man:break
    print((man.index(max(man))))        

# Optimized solution
while 1:
    n,p = list(map(int,input().split()))
    if n==0:break
    man =  [0]*n
    ball,a = p,0
    while 1:
        a%=n
        if ball >0:
            ball-=1
            man[a]+=1
        elif ball == 0:ball,man[a] = man[a],ball
        if man[a]==p:break
        a+=1
        
    print(a)
# Original solution
while 1:
    n,p = list(map(int,input().split()))
    if n==0:break
    man =  [0]*n
    ball,a = p,0
    while 1:
        a%=n
        if ball >0:
            ball-=1
            man[a]+=1
        elif ball == 0:ball,man[a] = man[a],ball
        if man[a]==p:break
        a+=1
        
    print(a)                

# Optimized solution
while 1:
    n,p = list(map(int,input().split()))
    if n==0:break
    man =  [0]*n
    ball,a = p,0
    while 1:
        a%=n
        if ball >0:
            ball-=1
            man[a]+=1
        elif ball == 0:ball,man[a] = man[a],ball
        if man[a]==p:break
        a+=1
    print((man.index(max(man))))
# Original solution
while 1:
	n,p = list(map(int,input().split()))
	if n == 0: break
	have = [0]*n
	stone = p
	i = count = 0
	while 1:
		count += 1
		if stone > 0:
			have[i] += 1
			stone -= 1
		else:
			stone += have[i]
			have[i] = 0
		if have[i] == p:
			break
		i = (i+1)%n
	print(i)

# Optimized solution
while 1:
	n,p = list(map(int,input().split()))
	if n == 0: break
	have = [0]*n
	stone = p
	i = 0
	while 1:
		if stone > 0:
			have[i] += 1
			stone -= 1
		else:
			stone += have[i]
			have[i] = 0
		if have[i] == p:
			break
		i = (i+1)%n
	print(i)
# Original solution
while 1:
	n,p = list(map(int,input().split()))
	if n == 0: break
	have = [0]*n
	stone = p
	i = 0
	while 1:
		if stone > 0:
			have[i] += 1
			stone -= 1
		else:
			stone += have[i]
			have[i] = 0
		if have[i] == p:
			break
		i = (i+1)%n
	print(i)

# Optimized solution
while 1:
	n,p = list(map(int,input().split()))
	if n == 0: break
	have = [0]*n
	cup = p
	i = 0
	while 1:
		if cup > 0:
			have[i] += 1
			cup -= 1
			if have[i] == p:
				break
		else:
			cup += have[i]
			have[i] = 0
		i = (i+1)%n
	print(i)
# Original solution
while True:
    n,p = list(map(int,input().split()))
    if n==p==0: break
    s,c = [0]*n,p
    i = 0
    while True:
        if c:
            c-=1
            s[i%n]+=1
            if s[i%n]==p: break
        else:
            c+=s[i%n]
            s[i%n] = 0
        i+=1
    print((i%n))

# Optimized solution
while True:
    n,p = list(map(int,input().split()))
    if n==p==0: break
    l = [0]*n
    i,k = 0,p
    while True:
        i %= n
        if k==0: k,l[i] = l[i],0
        else:
            k-=1
            l[i]+=1
            if l[i]==p: break
        i+=1
    print(i)
# Original solution
while True:
    n, p = list(map(int, input().split()))
    pp = p
    if n == p == 0:
        break
    stones = [0] * n
    i = 0
    while True:
        er = i % n
        if p == 1 and stones[er] == pp - 1:
            print(er)
            break
        if p >= 1:
            stones[er] += 1
            p -= 1
        else:
            p += stones[er]
            stones[er] = 0
        i += 1

# Optimized solution
while True:
    n, p = list(map(int, input().split()))
    pp = p
    if n == p == 0:
        break
    stones = [0] * n
    for i in range(1000000):
        er = i % n
        if p >= 1:
            stones[er] += 1
            p -= 1
            if p == 0 and stones[er] == pp:
                print(er)
                break
        else:
            p = stones[er]
            stones[er] = 0
# Original solution
from sys import stdin, stdout, stderr

while 1:
    n, p = list(map(int, stdin.readline().split()))

    if n + p == 0:
        break

    a = [0] * n
    wan = p

    for i in range(10**6):
        if wan > 0:
            a[i % n] += 1
            wan -= 1
        else:
            wan += a[i % n]
            a[i % n] = 0

        if a[i % n] == p:
            print((i % n))
            break

# Optimized solution
from sys import stdin, stdout, stderr

a = [0] * 50

while 1:
    n, p = list(map(int, stdin.readline().split()))

    if n + p == 0:
        break

    wan = p
    i = 0

    while a[i] < p:
        if wan > 0:
            a[i] += 1
            wan -= 1
        else:
            wan += a[i]
            a[i] = 0

        i = (i + 1) % n

    print(i)
    a[i] = 0
# Original solution
N, X = list(map(int, input().split()))
m = [int(eval(input())) for _ in range(N)]
result = len(m)
X -= sum(m)
while X >= min(m):
  result += 1
  X -= min(m)
print(result)

# Optimized solution
N, X = list(map(int, input().split()))
m = [int(eval(input())) for _ in range(N)]
print((len(m)+(X-sum(m))//min(m)))
# Original solution
n,x = list(map(int,input().split()))
y = 1000
for i in range(n):
    z = int(eval(input()))
    x -= z
    y = min(y,z)
print((n+x//y))


# Optimized solution
n,x=list(map(int,input().split()))
M=sorted([int(eval(input())) for i in range(n)])
print((len(M)+(x-sum(M))//M[0]))
# Original solution
n,x = list(map(int,input().split()))
m_list = [int(eval(input())) for _ in range(n)]

remaining = x - sum(m_list)
print((len(m_list) + (remaining//min(m_list))))

# Optimized solution
n,x = list(map(int,input().split()))
m_list = [int(eval(input())) for _ in range(n)]

remaining = x - sum(m_list)
print((n + (remaining//min(m_list))))
# Original solution
N, X = list(map(int, input().split()))

m = []
for i in range(N):
    m.append(int(eval(input())))

min_kona = 0
for val in m:
    min_kona += val

min_donut = min(m)
cnt = (X - min_kona) // min_donut + len(m)
print(cnt)

# Optimized solution
N, X = list(map(int, input().split()))

m = []
for i in range(N):
    m.append(int(eval(input())))

min_kona = sum(m)
min_donut = min(m)
cnt = (X - min_kona) // min_donut + len(m)
print(cnt)
# Original solution
N,X = list(map(int,input().split()))
m = [int(eval(input())) for i in range(N)]
m.sort()
ans = 0
for i in range(N):
    X -= m[i]
    if X < 0:
        break
    ans += 1
if X > 0:
    ans += X // min(m)
print(ans)

# Optimized solution
N,X = list(map(int,input().split()))
m = [int(eval(input())) for i in range(N)]

ans = N + (X - sum(m)) // min(m)
print(ans)
# Original solution
n,x=list(map(int, input().split()))
m=[int(eval(input())) for _ in range(n)]

count=0

for i in range(len(m)):
    if x>=m[i]:
        x-=m[i]
        count+=1
        
min_donut=min(m)
while(x>=min_donut):
    x-=min_donut
    count+=1
    
print(count)

# Optimized solution
n,x=list(map(int, input().split()))
m=[int(eval(input())) for _ in range(n)]

print(((x-sum(m))//min(m)+n))
# Original solution
n,x = list(map(int,input().split()))
m = []
for i in range(n):
    m.append(int(eval(input())))
print((n+int((x-sum(m))/min(m))))

# Optimized solution
N,X = list(map(int,input().split()))
m = []
for _ in range(N):
    m.append(int(eval(input())))
print(((X-sum(m))//min(m)+N))
# Original solution
N,X = list(map(int,input().split()))
M = [int(eval(input())) for i in range(N)]
X -= sum(M)
M.sort()
ans = -1
while X >= 0:
  X -= M[0]
  ans += 1
print((ans+N))


# Optimized solution
N, X = list(map(int,input().split()))
m = []
cnt = 0
for j in range(N):
  m.append(int(eval(input())))
a = X - sum(m)
cnt = a // min(m) + N
print(cnt)
# Original solution
N,X = list(map(int, input().split()))
m = [int(eval(input())) for i in range(N)]
for x in m:
  X -= x
m.sort()
n = int(X/m[0])
print((n + len(m)))

# Optimized solution
N,X = list(map(int,input().split()))
m = [int(eval(input())) for _ in range(N)]
ans = N
X -= sum(m)
m = min(m)
ans += X//m
print(ans)