XXI Berland Annual Fair is coming really soon! Traditionally fair consists of $n$ booths, arranged in a circle. The booths are numbered $1$ through $n$ clockwise with $n$ being adjacent to $1$. The $i$-th booths sells some candies for the price of $a_i$ burles per item. Each booth has an unlimited supply of candies.

Polycarp has decided to spend at most $T$ burles at the fair. However, he has some plan in mind for his path across the booths:  at first, he visits booth number $1$;  if he has enough burles to buy exactly one candy from the current booth, then he buys it immediately;  then he proceeds to the next booth in the clockwise order (regardless of if he bought a candy or not). 

Polycarp's money is finite, thus the process will end once he can no longer buy candy at any booth.

Calculate the number of candies Polycarp will buy.


-----Input-----

The first line contains two integers $n$ and $T$ ($1 \le n \le 2 \cdot 10^5$, $1 \le T \le 10^{18}$) — the number of booths at the fair and the initial amount of burles Polycarp has.

The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$) — the price of the single candy at booth number $i$.


-----Output-----

Print a single integer — the total number of candies Polycarp will buy.


-----Examples-----
Input
3 38
5 2 5

Output
10

Input
5 21
2 4 100 2 6

Output
6



-----Note-----

Let's consider the first example. Here are Polycarp's moves until he runs out of money:  Booth $1$, buys candy for $5$, $T = 33$;  Booth $2$, buys candy for $2$, $T = 31$;  Booth $3$, buys candy for $5$, $T = 26$;  Booth $1$, buys candy for $5$, $T = 21$;  Booth $2$, buys candy for $2$, $T = 19$;  Booth $3$, buys candy for $5$, $T = 14$;  Booth $1$, buys candy for $5$, $T = 9$;  Booth $2$, buys candy for $2$, $T = 7$;  Booth $3$, buys candy for $5$, $T = 2$;  Booth $1$, buys no candy, not enough money;  Booth $2$, buys candy for $2$, $T = 0$. 

No candy can be bought later. The total number of candies bought is $10$.

In the second example he has $1$ burle left at the end of his path, no candy can be bought with this amount.

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Complete search

Sorting

Data structures

Greedy algorithms


Solutions:
import sys
(n, T) = map(int, sys.stdin.readline().split())
booths = list(map(int, sys.stdin.readline().split()))
total_cost = 0
result = 0
cheapest_item = float('inf')
candle_count = 0
while T >= cheapest_item or cheapest_item == float('inf'):
	running_T = T
	total_cost = 0
	candle_count = 0
	for booth in booths:
		if booth < cheapest_item:
			cheapest_item = booth
		if booth <= running_T:
			candle_count += 1
			running_T -= booth
			total_cost += booth
	if total_cost:
		result += candle_count * (T // total_cost)
		T %= total_cost
print(result)


import random
(n, t) = (int(x) for x in input().split())
a = [int(x) for x in input().split()]
tot = sum(a)
candies = 0

def solve(cur, nxt, l):
	if l <= 0:
		return
	global candies
	global t
	global tot
	nxt = []
	revs = t // tot
	candies += revs * l
	t -= revs * tot
	for cost in cur:
		if cost <= t:
			t -= cost
			candies += 1
			nxt.append(cost)
		else:
			tot -= cost
			l -= 1
	solve(nxt, cur, l)
solve(a, [], n)
print(candies)


(n, t) = input().strip().split(' ')
(n, t) = (int(n), int(t))
arr = list(map(int, input().strip().split(' ')))
a = 0
flag = 1
while flag and t:
	cnt = 0
	x = t
	y = 0
	flag = 0
	for i in arr:
		if x >= i:
			cnt += 1
			x -= i
			y += i
			flag = 1
	if flag == 0:
		break
	ans = t // y
	t -= y * ans
	cnt *= ans
	a += cnt
print(a)


def buy(n, t, c, s):
	if len(c) == 0:
		return 0
	ans = 0
	if t >= s:
		ans += n * (t // s)
		t %= s
	nc = []
	for i in range(n):
		if t >= c[i]:
			nc.append(c[i])
			t -= c[i]
			ans += 1
		else:
			s -= c[i]
	ans += buy(len(nc), t, nc, s)
	return ans

def main():
	(n, t) = map(lambda x: int(x), input().split(' '))
	c = list(map(lambda x: int(x), input().split(' ')))
	s = sum(c)
	print(buy(n, t, c, s))
main()


(n, t) = [int(x) for x in input().split()]
a = [[int(x) for x in input().split()]]
k = 0
na = 0
ma = 1
while t >= ma:
	sa = sum(a[na])
	la = len(a[na])
	if t >= sa:
		k += la * (t // sa)
		t %= sa
	ma = min(a[na])
	a.append([])
	for ta in a[na]:
		if t >= ta:
			t -= ta
			k += 1
			a[na + 1].append(ta)
	na += 1
print(k)


import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
int1 = lambda x: int(x) - 1
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))
ilelec = lambda : map(int1, input().split())
alelec = lambda : list(map(int1, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])
(n, t) = ilele()
A = alele()
s = sum(A)
candy = t // s * n
mark = {}
tot = n
while True:
	b = 0
	t = t % s
	if t == 0:
		break
	for i in range(n):
		if A[i] > t and mark.get(i, -1) == -1:
			mark[i] = 1
			tot -= 1
			s -= A[i]
	if s == 0:
		break
	b = t // s * tot
	if b <= 0:
		for i in range(n):
			if mark.get(i, -1) == -1 and A[i] <= t:
				candy += 1
				t -= A[i]
	else:
		candy += b
print(candy)


(n, t) = map(int, input().split())
a = [int(x) for x in input().split()]
otv = 0

def rec(t, a):
	global otv
	s = 0
	for c in a:
		s += c
	kol = t // s
	kol = max(kol, 0)
	otv += kol * len(a)
	octat = t - kol * s
	res = []
	su = 0
	for c in a:
		if su + c <= octat:
			res.append(c)
			su += c
	if su == 0:
		print(otv)
		exit(0)
	rec(octat, res)
rec(t, a)


def f(lst, b):
	ans = 0
	while b:
		flag = True
		cmin = 0
		l = 0
		for i in lst:
			if b and i <= b:
				b -= i
				ans += 1
				cmin += i
				l += 1
				flag = False
		if cmin:
			l2 = b // cmin * cmin
			ans += l * (b // cmin)
			b -= l2
		if flag:
			break
	return ans
(a, b) = map(int, input().strip().split())
lst = list(map(int, input().strip().split()))
print(f(lst, b))


def get(tn, arr):
	st = cnt = 0
	for i in arr:
		if tn >= i:
			tn -= i
			st += i
			cnt += 1
	return (st, cnt)
(n, t) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
mm = min(a)
final = 0
while t >= mm:
	(st, cnt) = get(t, a)
	final += cnt * (t // st)
	t = t % st
print(final)


(n, t) = map(int, input().split())
A = [int(x) for x in input().split()]
result = 0
bought_any = True
while True:
	bought_any = False
	(amount, value) = (0, 0)
	for x in A:
		if x <= t:
			t -= x
			amount += 1
			value += x
			bought_any = True
	if not bought_any:
		break
	k = t // value
	t %= value
	result += (k + 1) * amount
print(result)


(N, T) = map(int, input().split())
A = [int(x) for x in input().split()]
ans = 0
while A and T > 0:
	sa = sum(A)
	if T >= sa:
		ans += T // sa * len(A)
		T %= sa
	else:
		for (i, a) in enumerate(A):
			if T <= 0:
				break
			if T >= a:
				T -= a
				ans += 1
		A = [a for a in A if a <= T]
print(ans)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
(ans, nn) = (0, n)
while t >= min(a) and nn > 0:
	tot = sum(a)
	ans += t // tot * nn
	t %= tot
	for i in range(n):
		if t < a[i]:
			nn -= 1
			a[i] = 0
		elif a[i] > 0:
			t -= a[i]
			ans += 1
print(ans)


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
ans = 0
while True:
	tmp = list()
	paid = 0
	for v in arr:
		if v <= t:
			tmp.append(v)
			t -= v
			paid += v
	if paid != 0:
		ans += len(tmp) * (1 + t // paid)
		t %= paid
	else:
		print(ans)
		exit(0)
	arr = tmp


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
x = min(a)
cands = 0
while t >= x:
	y = sum(a)
	if t >= y:
		f = len(a)
		cands += t // y * f
		t = t - t // y * y
	else:
		for item in a:
			if t >= item:
				t = t - item
				cands += 1
	a = [_ for _ in a if _ <= t]
print(cands)


(x, cost) = map(int, input().split())
z = list(map(int, input().split()))
total = 0
mini = min(z)
c1 = 0
item = 0
while cost >= mini:
	total = 0
	for i in range(len(z)):
		if total + z[i] <= cost:
			total += z[i]
			c1 += 1
	sets = cost // total
	item += sets * c1
	cost = cost % total
	sets = 0
	total = 0
	c1 = 0
print(item)


n = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
m = 0
while len(l) > 0:
	m += n[1] // sum(l) * len(l)
	n[1] %= sum(l)
	l = [i for i in l if i <= n[1]]
	for i in l:
		if n[1] - i >= 0:
			m += 1
			n[1] -= i
	else:
		l = [i for i in l if i <= n[1]]
print(m)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
mn = min(a)
ans = 0
while t >= mn:
	k = t
	m = 0
	for i in range(n):
		if a[i] <= k:
			k -= a[i]
			m += 1
	r = t // (t - k)
	ans += r * m
	t -= (t - k) * r
print(ans)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
s = 0
c = 0
while True:
	c = 0
	s = 0
	for i in a:
		if i <= t:
			t -= i
			s += i
			c += 1
	if c == 0:
		break
	ans += c
	if s <= t:
		ans += c * (t // s)
		t %= s
print(ans)


w = input().split(' ')
n = int(w[0])
t = int(w[1])
w = input().split(' ')
a = []
for i in w:
	a.append(int(i))
sm = 0
while True:
	c_candies = 0
	c_sum = 0
	for i in range(n):
		if t >= a[i]:
			c_candies += 1
			sm += 1
			c_sum += a[i]
			t -= a[i]
	if c_candies == 0:
		print(sm)
		exit(0)
	sm += c_candies * (t // c_sum)
	t = t % c_sum


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
xx = min(arr)
ans = 0
while xx <= t:
	c = 0
	s = 0
	for i in range(n):
		if t >= arr[i]:
			t -= arr[i]
			s += arr[i]
			c += 1
			ans += 1
	if s > 0 and c > 0:
		ans += t // s * c
	t = t % s
print(ans)


(n, m) = map(int, input().split())
t = list(map(int, input().split()))
wyn = 0
t_del = []
t2 = []
t_pom = []
t_min = 999999999999999999
tmp_sum = sum(t)
while True:
	tmp_sum = 0
	for y in range(0, len(t), +1):
		if m < t[y]:
			continue
		m -= t[y]
		wyn += 1
		t_pom.append(t[y])
		tmp_sum += t[y]
		if t[y] <= t_min:
			t_min = t[y]
	t = list(t_pom)
	t_pom = []
	if len(t) == 0 or m == 0 or m < t_min:
		break
	if tmp_sum <= m:
		wyn += len(t) * int(m / tmp_sum)
		m -= int(m / tmp_sum) * tmp_sum
	if m == 0:
		print(wyn)
		exit(0)
print(wyn)


def main(args):
	(n, t) = list(map(int, input().split()))
	prices = list(map(int, input().split()))
	loop_prices = sum(prices)
	loop_n = n
	tot = 0
	while loop_n > 0:
		c = t // loop_prices
		tot += c * loop_n
		t -= c * loop_prices
		loop_prices = 0
		for (i, v) in enumerate(prices):
			if loop_prices + v > t:
				prices[i] = 0
				loop_n -= 1
			else:
				loop_prices += v
	print(tot)
import sys
sys.exit(main(sys.argv))


def least_significant_bit(i):
	return i & -i

class FenwickTree:

	def __init__(self, values):
		self.n = len(values) + 1
		self.data = [0] * self.n
		for (i, v) in enumerate(values):
			self.add(i, v)

	def add(self, index, value):
		i = index + 1
		while i < self.n:
			self.data[i] += value
			i += least_significant_bit(i)

	def prefix_sum(self, index):
		i = index + 1
		result = 0
		while i > 0:
			result += self.data[i]
			i -= least_significant_bit(i)
		return result

	def range_sum(self, start, end):
		return self.prefix_sum(end) - self.prefix_sum(start - 1)

def main(args):
	(n, t) = list(map(int, input().split()))
	prices = list(map(int, input().split()))
	state = [1] * len(prices)
	fprices = FenwickTree(prices)
	fstate = FenwickTree(state)
	tot = 0
	while fstate.prefix_sum(n - 1) > 0:
		loop = fprices.prefix_sum(n - 1)
		c = t // loop
		tot += c * fstate.prefix_sum(n - 1)
		t -= c * loop
		while fprices.prefix_sum(n - 1) > t:
			(left, right) = (-1, n - 1)
			while left + 1 < right:
				mid = (left + right) // 2
				p = fprices.prefix_sum(mid)
				if p <= t:
					left = mid
				else:
					right = mid
			fstate.add(right, -1)
			fprices.add(right, -prices[right])
	print(tot)
	return 0
import sys
sys.exit(main(sys.argv))


import sys
(N, T) = list(map(int, sys.stdin.readline().strip().split()))
nums = list(map(int, sys.stdin.readline().strip().split()))
ret = 0
while True:
	t = 0
	count = 0
	for item in nums:
		if T >= t + item:
			t += item
			count += 1
	if not count:
		break
	ret += T // t * count
	T = T % t
print(ret)


(n, t) = map(int, input().split())
inrr = input().split()
a = []
for i in inrr:
	ii = int(i)
	if ii <= t:
		a.append(ii)
n = len(a)
if n == 0:
	print(0)
else:
	minier = min(a)
	ans = 0
	row = []
	for x in range(n):
		if a[x] <= t:
			row.append(a[x])
	while t >= minier:
		cou = 0
		summer = 0
		for x in row:
			if t >= x:
				ans += 1
				summer += x
				t -= x
				cou += 1
		if cou > 0:
			dopi = t // summer
			ans += dopi * cou
			t -= dopi * summer
	print(ans)


(n, T) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
while True:
	t = m = 0
	for x in a:
		if T - t >= x:
			t += x
			m += 1
	if not m:
		break
	ans += T // t * m
	T %= t
print(ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
res = 0
Min = min(a)
while k >= Min:
	s = 0
	cnt = 0
	for i in a:
		if i <= k:
			k -= i
			s += i
			cnt += 1
	res += cnt
	if s <= k:
		res += cnt * (k // s)
		k %= s
print(res)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, t) = map(int, input().split())
ai = list(map(int, input().split()))
dp = [0] * n
ct = 0
ct2 = 0
ct3 = 0
ans = 0
summai = sum(ai)
while ct2 < len(ai):
	i = 0
	while i < n:
		if dp[i] == 0:
			ct += ai[i]
			if ct > t:
				dp[i] = 1
				ct3 += ai[i]
				ct -= ai[i]
				ct2 += 1
		i += 1
	summai -= ct3
	if summai != 0:
		q = t // summai
		t -= summai * q
		ans += q * (len(ai) - ct2)
	ct3 = 0
	ct = 0
print(ans)


from sys import stdin
input = stdin.readline
(n, t) = map(int, input().split())
lst = list(map(int, input().split()))
s = sum(lst)
x = min(lst)
candy = n * (t // s)
t -= s * (t // s)
while t >= x:
	(s, c) = (0, 0)
	for i in lst:
		if i <= t - s:
			c += 1
			s += i
	candy += c * (t // s)
	t -= s * (t // s)
print(candy)


(n, t) = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
while t > 0:
	k = 0
	suma = 0
	t1 = t
	f = 0
	for i in range(n):
		if A[i] <= t1:
			suma += A[i]
			t1 -= A[i]
			k += 1
			f = 1
	if f == 1:
		ans = ans + k * (t // suma)
		t = t % suma
	else:
		break
print(ans)


In = lambda : map(int, input().split())
(n, T) = In()
a = list(In())
ans = 0
minv = min(a)
while T >= minv:
	count = 0
	t = T
	for v in a:
		if t >= v:
			count += 1
			t -= v
	s = T - t
	d = T // s
	ans += d * count
	T -= s * d
print(ans)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
sum1 = sum(a)
b = a.copy()
b.sort()
cnt = n * (t // sum1)
t %= sum1
i = 0
N = n
while n != 0 and t != 0:
	while len(b) and b[-1] > t:
		sum1 -= b[-1]
		b.pop()
		n -= 1
	if not len(b):
		break
	while a[i] > t:
		i += 1
		i %= N
	if sum1 == 0:
		break
	t -= a[i]
	cnt += 1
	cnt += n * (t // sum1)
	t %= sum1
	i += 1
	i %= N
print(cnt)


(n, T) = map(int, input().split())
L = list(map(int, input().split()))
res = 0
while len(L) > 0:
	s = sum(L)
	l = len(L)
	r = T // s
	res += r * l
	T -= r * s
	a = []
	for i in L:
		if T >= i:
			T -= i
			res += 1
			a.append(i)
	L = a
print(res)


import sys
from array import array
import typing as Tp

def input():
	return sys.stdin.buffer.readline().decode('utf-8')

def main():
	(n, money) = map(int, input().split())
	a = list(map(int, input().split()))
	(cost, cnt) = (sum(a), n)
	ans = 0
	while cnt:
		if cost <= money:
			ans += cnt * (money // cost)
			money %= cost
		(cost, cnt) = (0, 0)
		for x in a:
			if money >= x:
				cost += x
				cnt += 1
				money -= x
				ans += 1
	print(ans)
main()


import sys
(n, T) = [int(i) for i in sys.stdin.readline().strip().split()]
A = [int(i) for i in sys.stdin.readline().strip().split()]
r = T // sum(A) * n
T = T % sum(A)
S = list(range(n))
s = 0
k = 0
while S:
	U = []
	for i in S:
		if A[i] <= T:
			T = T - A[i]
			r = r + 1
			if A[i] <= T:
				U.append(i)
				k = k + 1
				s = s + A[i]
	S = U
	if s:
		r = r + T // s * k
		T = T % s
	k = 0
	s = 0
print(r)


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(n, t) = I()
l = I()
s = sum(l)
an = t // s * n
t = t % s
i = 0
mi = min(l)
while t >= mi:
	c = k = i = 0
	while i < n:
		if c + l[i] <= t:
			k += 1
			c += l[i]
		i += 1
	if c == 0:
		break
	an += t // c * k
	t = t % c
print(an)


def line():
	return map(int, input().split())
(n, t) = line()
a = list(line())
m = 0
w = sum(a)
while len(a) != 0:
	m += n * (t // w)
	t %= w
	r = []
	w = 0
	n = 0
	for q in a:
		if t >= q:
			t -= q
			m += 1
			r.append(q)
			w += q
			n += 1
	a = r
print(m)


(n, T) = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a)
t = n * (T // s)
left = T % s
b = {}
j = 0
temp = []
for i in range(n):
	b[i] = a[i]
while n > 0 and left > 0:
	for j in b:
		if left >= b[j]:
			t = t + 1
			left = left - b[j]
		else:
			n = n - 1
			s = s - b[j]
			temp.append(j)
	for k in temp:
		del b[k]
	temp.clear()
	if left > s > 0:
		t = t + n * (left // s)
		left = left % s
print(t)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import factorial
from collections import Counter, defaultdict
from heapq import heapify, heappop, heappush

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 998244353
INF = float('inf')
from bisect import bisect_right

def main():
	(n, t) = RL()
	arr = RLL()
	sm = [0]
	for i in arr:
		sm.append(sm[-1] + i)
	res = t // sm[-1] * n
	t -= res // n * sm[-1]
	mi = min(arr)
	while t >= mi:
		use = 0
		nres = 0
		for i in arr:
			if i <= t:
				res += 1
				nres += 1
				t -= i
				use += i
		res += t // use * nres
		t -= t // use * use
	print(res)
main()


(n, t) = list(map(int, input().split()))
a = list(map(int, input().split()))
_ = min(a)
r = 0
s = sum(a)
n_ = n
while t >= _:
	v = int(t / s)
	r += v * n_
	t -= v * s
	for i in range(n):
		if a[i] == 0:
			continue
		if t >= a[i]:
			r += 1
			t -= a[i]
		else:
			n_ -= 1
			s -= a[i]
			a[i] = 0
print(r)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
x = min(a)
ans = 0
sum1 = 0
cnt = 0
while k >= x:
	sum1 = 0
	cnt = 0
	for i in range(n):
		if a[i] <= k:
			sum1 = sum1 + a[i]
			cnt = cnt + 1
	t = cnt * (k // sum1)
	ans = ans + t
	k = k % sum1
	for i in range(n):
		if a[i] <= k:
			ans = ans + 1
			k = k - a[i]
print(ans)


(n, T) = input().split()
n = int(n)
T = int(T)
tendas = list(map(int, input().split()))
doces = 0
minimo = min(tendas)
while T >= minimo:
	soma = 0
	cont = 0
	for i in range(n):
		if soma + tendas[i] <= T:
			soma += tendas[i]
			cont += 1
	doces += cont * (T // soma)
	T = T % soma
print(doces)


(n, T) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
while True:
	t = 0
	cnt = 0
	for i in a:
		if T - t >= i:
			t += i
			cnt += 1
	if not cnt:
		break
	ans += T // t * cnt
	T %= t
print(ans)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = 0
while k >= min(a):
	s = 0
	count = 0
	for i in a:
		if i <= k:
			k -= i
			s += i
			count += 1
	ans += k // s * count + count
	k -= k // s * s
print(ans)


def inint():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def main():
	(n, t) = inlist()
	a = inlist()
	sol = 0
	while True:
		ss = 0
		amt = 0
		for i in a:
			if i <= t:
				sol += 1
				ss += i
				t -= i
				amt += 1
		if amt == 0:
			break
		sol += t // ss * amt
		t = t % ss
	print(sol)
main()


I = lambda : map(int, input().split())
(n, t) = I()
a = list(I())
ans = 0
x = min(a)
while t >= x:
	y = t
	z = 0
	for i in a:
		if y >= i:
			z += 1
			y -= i
	r = t // (t - y)
	ans += z * r
	t -= (t - y) * r
print(ans)


def main():
	(n, t) = map(int, input().split())
	a = [int(i) for i in input().split()]
	x = min(a)
	ans = 0
	while t >= x:
		cnt = 0
		s = 0
		tau = t
		for i in range(n):
			if tau >= a[i]:
				tau -= a[i]
				s += a[i]
				cnt += 1
		ans += cnt * (t // s)
		t %= s
	print(ans)
main()


(n, t) = map(int, input().split())
u = list(map(int, input().split()))
ans = 0
s = sum(u)
while 1 == 1:
	ans += t // s * n
	t = t % s
	t1 = t
	u1 = []
	for i in range(n):
		if u[i] <= t:
			t -= u[i]
			u1.append(u[i])
			ans += 1
		else:
			s -= u[i]
			n -= 1
	u = u1[:]
	if t == t1:
		break
print(ans)


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
a = min(l)
ans = 0
while t >= a:
	c = 0
	d = 0
	for i in range(n):
		if l[i] <= t:
			t -= l[i]
			c += l[i]
			d += 1
	ans += d + t // c * d
	t %= c
print(ans)


import sys
input = sys.stdin.readline
(n, t) = map(int, input().split())
l = list(map(int, input().split()))
minn = min(l)
ans = 0
while t >= minn:
	c = 0
	count = 0
	for i in l:
		if i <= t:
			count += i
			t -= i
			c += 1
	t += count
	ans += c * (t // count)
	t = t % count
print(ans)


def main():
	(N, money) = list(map(int, input().split()))
	candies = list(map(int, input().split()))
	number_of_candies_bought = 0
	current_money = money
	while True:
		current_number_of_candies_bought = 0
		total_price = 0
		for candy in candies:
			if total_price + candy <= current_money:
				current_number_of_candies_bought += 1
				total_price += candy
		if current_number_of_candies_bought == 0:
			break
		number_of_iteration = current_money // total_price
		number_of_candies_bought += number_of_iteration * current_number_of_candies_bought
		current_money -= number_of_iteration * total_price
	print(number_of_candies_bought)
main()


from sys import stdin, stdout
from collections import defaultdict, Counter
from bisect import bisect
import math
I = stdin.readline
(n, t) = map(int, I().split())
arr = [int(x) for x in I().split()]
ans = 0
l = 0
while arr and t >= min(arr):
	new = []
	x = t
	for i in arr:
		if x >= i:
			x -= i
			new.append(i)
		if x == 0:
			break
	if new:
		s = sum(new)
		ans += t // s * len(new)
		t = t % s
		arr = new
	else:
		break
	l += 1
print(ans)


import sys
import math
import operator as op
from functools import reduce

def read_line():
	return sys.stdin.readline()[:-1]

def read_int():
	return int(sys.stdin.readline())

def read_int_line():
	return [int(v) for v in sys.stdin.readline().split()]

def read_float_line():
	return [float(v) for v in sys.stdin.readline().split()]

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer / denom
(n, t) = read_int_line()
a = read_int_line()
ans = 0
while t > 0:
	c = 0
	s = 0
	for i in range(n):
		if a[i] <= t - c:
			c += a[i]
			s += 1
	if s == 0:
		break
	ans += s * (t // c)
	t = t % c
print(ans)


(n, k) = map(int, input().split())
l = [int(i) for i in input().split()]
cnt = 0
n = len(l)
k1 = k % sum(l)
mini = min(l)

def calc(k1):
	cnt = 0
	sm = 0
	for i in l:
		if k1 >= i:
			k1 -= i
			cnt += 1
			sm += i
	return (cnt, sm)
ans = k // sum(l) * n
k1 = k % sum(l)
while k1 >= mini:
	(cnt, sm) = calc(k1)
	ans += k1 // sm * cnt
	k1 = k1 % sm
print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(N, T) = map(int, input().split())
a = [int(x) for x in input().split()]
(ans, n) = (0, N)
while T >= min(a) and n > 0:
	tot = sum(a)
	ans += T // tot * n
	T %= tot
	for i in range(N):
		if T < a[i]:
			n -= 1
			a[i] = 0
		elif a[i] > 0:
			T -= a[i]
			ans += 1
print(ans)


from sys import stdin
input = stdin.readline
(n, t) = map(int, input().split())
l = list(map(int, input().split()))
s = sum(l)
(cnt, d) = (0, [1] * n)
tot = 0
while cnt < n:
	if t >= s and s > 0:
		tot += t // s * (n - cnt)
		t %= s
	if t < s:
		curr = 0
		for i in range(n):
			if d[i]:
				if curr + l[i] > t:
					d[i] = 0
					cnt += 1
				else:
					curr += l[i]
		s = curr
print(tot)


(n, T) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
candies = 0
remaining = len(a)
min_a = min(a)
while remaining > 0:
	for (i, ai) in enumerate(a):
		if ai > T:
			a[i] = 0
			remaining -= 1
	if remaining == 0:
		break
	round_cost = sum(a)
	max_full_rounds = T // round_cost
	if max_full_rounds == 0:
		for ai in a:
			if ai != 0 and ai <= T:
				T -= ai
				candies += 1
	candies += max_full_rounds * remaining
	T -= max_full_rounds * round_cost
print(candies)


(n, k) = [*map(int, input().split())]
numbers = [*map(int, input().split())]
count = 0
suma = sum(numbers)
sorted_numbers = sorted(numbers)
count_numbers = len(numbers)
while count_numbers != 0:
	ile = k // suma
	if ile >= 1:
		count += count_numbers * ile
		k -= suma * ile
	else:
		copy = []
		for val in numbers:
			if k >= val:
				k -= val
				count += 1
				copy.append(val)
		numbers = copy
	while count_numbers != 0 and sorted_numbers[count_numbers - 1] > k:
		count_numbers -= 1
		suma -= sorted_numbers[count_numbers]
print(count)


(n, t) = list(map(int, input().strip().split()))
a = list(map(int, input().strip().split()))
s0 = 0
b = sorted(a, reverse=True)
big = b[0]
s = []
s0 = sum(b)
for i in b:
	s.append(s0)
	s0 -= i
money = t
ans = 0
for (i, total) in enumerate(s):
	big1 = b[i]
	if money >= total:
		ans += (n - i) * (money // total)
		money -= total * (money // total)
	if money < big1:
		continue
	else:
		while money >= big1:
			f1 = True
			for ls in range(n):
				if money - a[ls] >= 0:
					money -= a[ls]
					f1 = False
					ans += 1
				else:
					pass
				ls += 1
			if f1 == True:
				break
		if f1 == True:
			break
print(ans)


import sys

def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var, sep=' ', end='\n'):
	print(*var, file=sys.stderr, end=end, sep=sep)
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(n, k) = I()
a = I()
ans = 0
while k > 0:
	cur = 0
	candies = 0
	for i in range(n):
		if cur + a[i] <= k:
			cur += a[i]
			candies += 1
			continue
	if candies == 0:
		break
	ans += k // cur * candies
	k = k % cur
print(ans)


import bisect
import sys
input = sys.stdin.readline
(n, t) = map(int, input().split())
ar = list(map(int, input().split()))
li = ar.copy()
li.sort()
br = [li[0]]
for i in range(1, n):
	br.append(br[-1] + li[i])
ans = 0
while True:
	xx = bisect.bisect(li, t)
	if xx == 0:
		break
	else:
		xx -= 1
	if t >= br[xx]:
		roun = t // br[xx]
		ans += (xx + 1) * roun
		t -= br[xx] * roun
	else:
		for i in range(n):
			if ar[i] <= t:
				ans += 1
				t -= ar[i]
print(ans)


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
p = sum(l)
s = 0
s += n * (t // p)
t -= p * (t // p)
x = min(l)
i = 0
while t >= x:
	countinround = 0
	costround = 0
	p = t
	for i in l:
		if p >= i:
			countinround += 1
			costround += i
			p -= i
	if costround == 0:
		break
	rounds = t // costround
	t -= rounds * costround
	count = rounds * countinround
	s += count
print(s)


(n, t) = map(int, input().split())
cost = [int(x) for x in input().split()]
(mn, ans) = (min(cost), 0)
while t >= mn:
	(val, cnt, curr_money) = (0, 0, t)
	for i in range(0, len(cost)):
		if t >= cost[i]:
			t -= cost[i]
			val += cost[i]
			cnt += 1
	ans += curr_money // val * cnt
	t %= val
print(ans)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in a:
	if i <= t:
		b.append(i)
c = 0
n = len(b)
s = sum(b)
while len(b) > 0 and t >= min(b):
	if s <= t:
		k = t // s
		t -= s * k
		c += n * k
	else:
		for i in b:
			if i <= t:
				t -= i
				c += 1
	d = b
	z = []
	for i in d:
		if i <= t:
			z.append(i)
	b = z
	n = len(b)
	s = sum(b)
	if n == 0:
		break
print(c)


(booths, money) = map(int, input().split())
prices = list(map(int, input().split()))
ans = 0
sum_prices = sum(prices)
while len(prices) > 0:
	ans += booths * (money // sum_prices)
	money %= sum_prices
	r = []
	sum_prices = 0
	booths = 0
	for p in prices:
		if money >= p:
			money -= p
			ans += 1
			r.append(p)
			sum_prices += p
			booths += 1
	prices = r
print(ans)


(n, t) = list(map(int, input().split()))
a = [int(x) for x in input().split()]
otv = 0

def rec(t, a):
	nonlocal otv
	s = 0
	for c in a:
		s += c
	kol = t // s
	kol = max(kol, 0)
	otv += kol * len(a)
	octat = t - kol * s
	res = []
	su = 0
	for c in a:
		if su + c <= octat:
			res.append(c)
			su += c
	if su == 0:
		print(otv)
		return
	rec(octat, res)
rec(t, a)


(n, T) = list(map(int, input().split()))
a = list(map(int, input().split()))
summ = []
cur = 0
mmin = a[0]
for item in a:
	cur += item
	summ.append(cur)
	mmin = min(item, mmin)

def helper(x, l, r=n - 1):
	z = l
	while l < r:
		mid = (l + r) // 2
		cur = summ[mid] - summ[z] + a[z]
		if cur <= x:
			l = mid + 1
		else:
			r = mid
	if summ[l] - summ[z] + a[z] > x:
		return l
	else:
		return l + 1

def helper2(x, l, r=n - 1):
	cur = l
	while cur <= r and summ[cur] - summ[l] + a[l] <= x:
		cur += 1
	return cur
ans = 0
left = T
d = {}
while T >= mmin:
	l = 0
	(t, num) = (0, 0)
	left = T
	while left >= mmin and l < n:
		r = helper2(left, l)
		if l == r:
			l += 1
			continue
		t += summ[r - 1] - summ[l] + a[l]
		num += r - l
		left -= summ[r - 1] - summ[l] + a[l]
		l = r + 1
	ans += T // t * num
	T = T % t
print(ans)


(n, amount) = map(int, input().split())
fair = []
fair = list(map(int, input().split()))
minP = min(fair)
candies = 0
while amount >= minP:
	price = 0
	count = 0
	copieAmount = amount
	for i in range(n):
		if copieAmount >= fair[i]:
			copieAmount -= fair[i]
			price += fair[i]
			count += 1
	candies += count * (amount // price)
	amount = amount % price
print(candies)


(n, tot) = map(int, input().split())
arr = list(map(int, input().split()))
p = tot
can = 0
while 1:
	temp = 0
	cnt = 0
	for i in range(n):
		if temp + arr[i] <= p:
			temp += arr[i]
			cnt += 1
	if cnt == 0:
		break
	can += p // temp * cnt
	p = p % temp
print(can)


(n, money) = map(int, input().split())
booths = list(map(int, input().split()))
min_val = min(booths)
result = 0
while money >= min_val:
	candies = 0
	total = 0
	run_money = money
	for val in booths:
		if val <= run_money:
			total += val
			candies += 1
			run_money -= val
	result += money // total * candies
	money = money % total
print(result)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
while True:
	b = False
	k = 0
	s = 0
	for i in range(n):
		if t >= a[i]:
			s += a[i]
			k += 1
			b = True
	if not b:
		break
	if t < s:
		for i in range(n):
			if t >= a[i]:
				ans += 1
				t -= a[i]
	else:
		ans += t // s * k
		t %= s
print(ans)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
result = 0
min_ = t
a_ = a
while t >= min_:
	loop_sum = 0
	next_a = []
	for el in a_:
		if t - loop_sum >= el:
			loop_sum += el
			next_a.append(el)
		min_ = min(min_, el)
		if t == loop_sum:
			break
	if len(next_a) == 0:
		break
	else:
		a_ = next_a
		loops = t // loop_sum
		result += len(next_a) * loops
		t -= loops * loop_sum
print(result)


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

def read_int():
	return int(stdin.readline())

def read_ints():
	return [int(x) for x in stdin.readline().split()]

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]
(nb_shop, has_amt) = read_ints()
prices = read_ints()
sums = sum(prices)
ans = 0
size = nb_shop
while size:
	(curr, has_amt) = divmod(has_amt, sums)
	ans += curr * size
	sums = 0
	for i in range(nb_shop):
		if sums + prices[i] > has_amt:
			prices[i] = 0
			size -= 1
		sums += prices[i]
print(ans)


def main():
	(n, T) = map(int, input().split())
	ls = map(int, input().split())
	a = list(ls)
	ans = 0
	while 1:
		if T < min(a):
			break
		s = 0
		cnt = 0
		for x in a:
			if s + x <= T:
				s += x
				cnt += 1
		ans += T // s * cnt
		T -= T // s * s
	print(ans)
main()


import os
import sys
from io import BytesIO, IOBase
import math
import itertools
import bisect
import heapq
sys.setrecursionlimit(300000)

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	return l

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)

def countcon(s, i):
	c = 0
	ch = s[i]
	for i in range(i, len(s)):
		if s[i] == ch:
			c += 1
		else:
			break
	return c

def lis(arr):
	n = len(arr)
	lis = [1] * n
	for i in range(1, n):
		for j in range(0, i):
			if arr[i] > arr[j] and lis[i] < lis[j] + 1:
				lis[i] = lis[j] + 1
	maximum = 0
	for i in range(n):
		maximum = max(maximum, lis[i])
	return maximum

def isSubSequence(str1, str2):
	m = len(str1)
	n = len(str2)
	j = 0
	i = 0
	while j < m and i < n:
		if str1[j] == str2[i]:
			j = j + 1
		i = i + 1
	return j == m

def maxfac(n):
	root = int(n ** 0.5)
	for i in range(2, root + 1):
		if n % i == 0:
			return n // i
	return n

def p2(n):
	c = 0
	while n % 2 == 0:
		n //= 2
		c += 1
	return c

def seive(n):
	primes = [True] * (n + 1)
	primes[1] = primes[0] = False
	for i in range(2, n + 1):
		if primes[i]:
			for j in range(i + i, n + 1, i):
				primes[j] = False
	p = []
	for i in range(0, n + 1):
		if primes[i]:
			p.append(i)
	return p

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def denofactinverse(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return pow(fac, m - 2, m)

def numofact(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return fac
(n, t) = map(int, input().split())
l = list(map(int, input().split()))
m = min(l)
ans = 0
while t >= m:
	temp = t
	x = 0
	bs = 0
	for i in range(0, n):
		if l[i] <= temp:
			temp -= l[i]
			x += 1
			bs += l[i]
	ans += x * (t // bs)
	t %= bs
print(ans)


def update(indx):
	sgn_tree[indx] = 0
	indx = indx >> 1
	while indx >= 1:
		sgn_tree[indx] = sgn_tree[indx << 1] + sgn_tree[(indx << 1) + 1]
		indx = indx >> 1

def queries(l, r):
	add = 0
	while l <= r:
		if l % 2 == 1:
			add += sgn_tree[l]
			l += 1
		if r % 2 == 0:
			add += sgn_tree[r]
			r -= 1
		l = l >> 1
		r = r >> 1
	return add
(n, cost) = map(int, input().split())
a = list(map(int, input().split()))
sgn_tree = [0] * (2 * n)
for i in range(n, 2 * n):
	sgn_tree[i] = a[i - n]
for i in range(n - 1, 0, -1):
	sgn_tree[i] = sgn_tree[i << 1] + sgn_tree[(i << 1) + 1]
i = 0
count = 0
while i < n:
	if cost >= sgn_tree[1]:
		count += cost // sgn_tree[1] * (n - i)
		cost = cost % sgn_tree[1]
	(l, r) = (n, 2 * n - 1)
	while l < r:
		m = (l + r) // 2
		if queries(n, m) <= cost:
			l = m + 1
		else:
			r = m - 1
	if queries(n, l) <= cost:
		update(l + 1)
	else:
		update(l)
	i += 1
print(count)


import sys
import bisect
input = sys.stdin.readline
t = 1
mod = 10 ** 9 + 7
for _ in range(t):
	(n, r) = map(int, input().split())
	l = list(map(int, input().split()))
	mini = min(l[:])
	ans = 0
	while r >= mini:
		l2 = []
		suma = 0
		for i in range(n):
			if l[i] <= r:
				suma += l[i]
				l2.append(l[i])
		if suma <= r:
			ans += len(l2) * (r // suma)
			r %= suma
		else:
			for i in l2:
				if i <= r:
					r -= i
					ans += 1
	print(ans)


(n, T) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
candy = 0
while True:
	endCycle = True
	roundMoney = 0
	roundCandy = 0
	for x in a:
		if T >= x:
			endCycle = False
			T -= x
			roundMoney += x
			roundCandy += 1
	if roundMoney:
		candy += roundCandy * (T // roundMoney + 1)
		T %= roundMoney
	if endCycle or T == 0:
		print(candy)
		break


(n, T) = list(map(int, input().split()))
A = list(map(int, input().split()))
AIND = [(A[i], i) for i in range(n)]
AS = sorted(AIND)
MINA = AS[0][0]
SUM = [AS[0][0]]
for i in range(1, n):
	SUM.append(AS[i][0] + SUM[-1])
SUM.reverse()
AS.reverse()
MAX = SUM[0]
x = 0
ANS = 0
while T >= MINA:
	if T > SUM[x]:
		ANS += (n - x) * (T // SUM[x])
		T = T % SUM[x]
	elif T < AS[x][0]:
		x += 1
	else:
		for i in range(n):
			if T >= A[i]:
				T -= A[i]
				ANS += 1
print(ANS)


(n, t) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
ans = 0
while t > 0 and len(a) > 0:
	s = sum(a)
	ans += t // s * len(a)
	t = t % s
	b = []
	for i in range(len(a)):
		if a[i] <= t:
			ans += 1
			t -= a[i]
			if a[i] <= t:
				b.append(a[i])
			if t < 0:
				break
	a = b
print(ans)


line1 = input().split()
line2 = input().split()
(Booths, Money) = map(int, line1)
Price = list(map(int, line2))
Count = 0
cur = 0
mini = min(Price)
Skip = set()
pre = Money
pre_count = 0
while Money >= mini:
	if cur not in Skip:
		if Price[cur] <= Money:
			Money -= Price[cur]
			Count += 1
		else:
			Skip.add(cur)
	cur += 1
	if cur == Booths:
		cycle1 = pre - Money
		count1 = Count - pre_count
		round = Money // cycle1
		Money %= cycle1
		Count += count1 * round
		pre = Money
		pre_count = Count
		cur = 0
print(Count)


from bisect import bisect_right as br
(n, t) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
l = min(a)
while t >= l:
	k = t
	m = 0
	for i in a:
		if k >= i:
			m += 1
			k -= i
	r = t // (t - k)
	ans += r * m
	t -= (t - k) * r
print(ans)


from collections import deque

def count(e, k):
	c = 0
	mi = min(e)
	for i in range(len(e)):
		if k < mi:
			break
		k -= e[i]
		c += 1
		if k < 0:
			k += e[i]
			c -= 1
	return [c, k]
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
e = [] + l
l.sort()
su = sum(l)
l = deque(l)
ans = 0
while k > 0:
	if su == 0:
		break
	if k < su:
		if k < l[-1]:
			su -= l[-1]
			l.pop()
		else:
			(c, k) = count(e, k)
			ans += c
	else:
		ans += k // su * len(l)
		k -= su * (k // su)
print(ans)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
suma = sum(a)
a = {i: a[i] for i in range(n)}
ans = 0
c = 0
left = n
while suma != 0:
	ans += t // suma * left
	t = t % suma
	while suma > t:
		if c in a:
			if t < a[c]:
				suma -= a[c]
				left -= 1
				del a[c]
			else:
				t -= a[c]
				ans += 1
		c = (c + 1) % n
print(ans)


(N, T) = map(int, input().split())
a = [int(x) for x in input().split()]
(ans, n) = (0, N)
while T >= min(a) and n > 0:
	tot = sum(a)
	ans += T // tot * n
	T %= tot
	for i in range(N):
		if T < a[i]:
			n -= 1
			a[i] = 0
		elif a[i] > 0:
			T -= a[i]
			ans += 1
print(ans)


import math as ma
import sys
from sys import exit
from decimal import Decimal as dec
from itertools import permutations

def li():
	return list(map(int, input().split()))

def num():
	return map(int, input().split())

def nu():
	return int(input())

def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
(n, t) = num()
a = li()
count = n
z = 0
while count > 0 and sum(a) > 0:
	pp = 0
	z += t // sum(a) * count
	t = t % sum(a)
	for i in range(n):
		if t >= a[i] and a[i] != 0:
			pp += 1
			t -= a[i]
		else:
			a[i] = 0
	count = pp
	z += pp
print(z)


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
sys.setrecursionlimit(10 ** 5)
from queue import PriorityQueue
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
(n, t) = map(int, input().split())
l = list(map(int, input().split()))
i = 0
ans = 0
while True:
	tot = 0
	cnt = 0
	for i in range(n):
		if tot + l[i] <= t:
			tot += l[i]
			cnt += 1
	if tot == 0:
		break
	ans += t // tot * cnt
	t -= tot * (t // tot)
	if t == 0:
		break
print(ans)


R = lambda : map(int, input().split())
(n, T) = R()
a = list(R())
res = 0
while 1:
	(acc, cnt) = (0, 0)
	for x in a:
		if acc + x <= T:
			acc += x
			cnt += 1
	if not acc:
		break
	res += T // acc * cnt
	T %= acc
print(res)


def func(n, t, a):
	count = 0
	s = sum(a)
	z = []
	if t >= s:
		count += t // s * n
		t %= s
	for i in a:
		if t >= i:
			z.append(i)
			count += 1
			t -= i
	if t >= min(a):
		count += func(len(z), t, z)
	return count
(n, t) = map(int, input().split())
a = list(map(int, input().split()))
print(func(n, t, a))


I = lambda : list(map(int, input().split()))
(n, have) = I()
l = I()
ans = 0
while have:
	got = 0
	temp = 0
	i = 0
	while i < n:
		if have - (temp + l[i]) >= 0:
			temp += l[i]
			got += 1
		i += 1
	if not got:
		break
	ans += have // temp * got
	have %= temp
print(ans)


from heapq import heappush as add, heappop as pop, heapify, heapreplace as replace, nlargest, nsmallest

def cal(c, k):
	p = 0
	while k >= min(c):
		t = 0
		x = 0
		q = len(c)
		for i in range(q):
			if c[i] <= k and k > 0:
				k = k - c[i]
				x = x + c[i]
				c.append(c[i])
				t = t + 1
		c = c[q:]
		if len(c) == 0:
			return p
		t = t + k // x * t
		k = k % x
		p = p + t
	return p
(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
print(cal(a, k))


from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def main():
	(n, s) = mi()
	a = li()
	s1 = sum(a)
	ans = 0
	if s >= s1:
		x = s // s1
		ans += x * n
		s -= x * s1
	while 1:
		b = []
		for i in a:
			if i <= s:
				s -= i
				ans += 1
				b.append(i)
		a = b[:]
		if s == 0 or len(a) == 0:
			break
		if s >= sum(a):
			n = len(a)
			s1 = sum(a)
			x = s // s1
			ans += x * n
			s -= x * s1
		if len(a) == 1:
			ans += s // a[0]
			break
	print(ans)
main()


import sys
from collections import defaultdict, deque
import heapq
(n, t) = map(int, sys.stdin.readline().split())
arr = list(map(int, sys.stdin.readline().split()))
pre = []
s = 0
for i in range(n):
	s += arr[i]
	pre.append(s)
ans = 0
x = min(arr)
while t >= x:
	(cost, cnt) = (0, 0)
	rem = t
	for i in range(n):
		if rem >= arr[i]:
			rem -= arr[i]
			cnt += 1
	delta = t - rem
	sweet = t // delta * cnt
	t = t % delta
	ans += sweet
print(ans)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, t) = map(int, input().split())
a = list(map(int, input().split()))
tot = sum(a)
res = t // tot * n
t %= tot
while t >= min(a):
	b = list()
	c = t
	ct = 0
	cost = 0
	for i in a:
		if i <= c:
			c -= i
			cost += i
			ct += 1
	res += t // cost * ct
	t %= cost
	for i in a:
		if i <= t:
			b.append(i)
	a = list(b)
	if len(a) == 0:
		break
print(res)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
d = min(a)
ans = 0
while k >= d:
	tc = 0
	kol = 0
	K = k
	for i in range(n):
		if K >= a[i]:
			K -= a[i]
			tc += a[i]
			kol += 1
	ans += kol * (k // tc)
	k %= tc
print(ans)


(n, T) = map(int, input().split())
costs = input().split()
costs = map(int, costs)
costs = list(costs)
min_cost = min(costs)
confets = 0
while T >= min_cost:
	c = T
	curr = 0
	spent = 0
	for x in costs:
		if x <= c:
			curr += 1
			spent += x
			c -= x
	confets += T // spent * curr
	T = T % spent
	costs = filter(lambda x: x <= T, costs)
	costs = list(costs)
print(confets)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, T) = map(int, input().split())
arr = list(map(int, input().split()))
ans = 0
while True:
	t = 0
	m = 0
	var = T
	for i in arr:
		if var >= i:
			var -= i
			t += i
			m += 1
	if m == 0:
		break
	else:
		ans += T // t * m
		T = T % t
print(ans)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
while t > 0:
	sum = 0
	cnt = 0
	cur = t
	for i in range(n):
		if a[i] <= cur:
			sum += a[i]
			cnt += 1
			cur -= a[i]
	if cnt == 0:
		break
	ans += cnt * (t // sum)
	t %= sum
print(ans)


(n, T) = map(int, input().split())
a = list(map(int, input().split()))
cur = 0
ased = a[:]
ased.sort(key=lambda x: -x)
ased += [0]
s = sum(a)
r = 0
while cur != n:
	while ased[cur] > T:
		s -= ased[cur]
		cur += 1
	if s <= T and s > 0:
		(d, T) = divmod(T, s)
		r += d * (n - cur)
		continue
	for i in range(n):
		if a[i] <= T:
			T -= a[i]
			r += 1
print(r)


(n, m) = list(map(int, input().split()))
l = list(map(int, input().split()))
minimum = min(l)
ans = 0
while m >= minimum:
	c = t = 0
	for i in l:
		if i + t <= m:
			t += i
			c += 1
	ans += m // t * c
	m %= t
print(ans)


import copy
(n, T) = list(map(int, input().split()))
A = list(map(int, input().split()))
s = sum(A)
ans = 0
B = []
for a in A:
	if a <= T:
		B.append(a)
	else:
		s -= a
while len(B) > 0:
	loop = T // s
	if loop == 0:
		for i in range(len(A)):
			if T >= A[i]:
				ans += 1
				T -= A[i]
	else:
		ans += loop * len(B)
		T %= s
	A = copy.deepcopy(B)
	B = []
	for a in A:
		if a <= T:
			B.append(a)
		else:
			s -= a
print(ans)


import sys
from bisect import bisect
fin = sys.stdin.readline
(n, T) = [int(elem) for elem in fin().split(' ')]
a_list = [int(elem) for elem in fin().split(' ')]
num_candies = 0
whole_price = sum(a_list)
while T > 0:
	reduced = 0
	num_reduced = 0
	for a in a_list:
		if T == 0:
			break
		if T >= a:
			T -= a
			reduced += a
			num_reduced += 1
			num_candies += 1
	if reduced == 0:
		break
	elif T // reduced >= 1:
		num_candies += num_reduced * (T // reduced)
		T %= reduced
print(num_candies)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
sum1 = 0
for i in range(n):
	sum1 += a[i]
b = t % sum1
bought = t // sum1 * n
k = 0
l = min(a)
gone = [0] * n
while b >= l:
	for i in range(n):
		if a[i] > b and gone[i] == 0:
			k += 1
			gone[i] = 1
			sum1 -= a[i]
	bought += b // sum1 * (n - k)
	b = b % sum1
	if b // sum1 == 0:
		for i in range(n):
			if a[i] <= b:
				bought += 1
				b -= a[i]
print(bought)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
(n, ammount) = Ri()
a = Ri()
summ = sum(a)
tot = n
ans = 0
while True:
	ans = ans + tot * (ammount // summ)
	ammount = ammount % summ
	cnt = 0
	summ = 0
	for i in range(n):
		if a[i] + summ <= ammount:
			summ += a[i]
			cnt += 1
	tot = cnt
	if cnt == 0:
		break
print(ans)


def splitInput():
	return list(map(int, input().split()))
nT = splitInput()
money = nT[1]
kioski = list(filter(lambda x: x <= money, splitInput()))
konfet = 0
if len(kioski) > 0:
	minKioskiPrice = min(kioski)
	while money >= minKioskiPrice:
		sumKioski = sum(kioski)
		countCycles = money // sumKioski
		if countCycles > 0:
			konfet += countCycles * len(kioski)
			money -= sumKioski * countCycles
		for k in kioski:
			if k <= money:
				money -= k
				konfet += 1
			if money < minKioskiPrice:
				break
		kioski = list(filter(lambda x: x <= money, kioski))
print(konfet)


def sum(a):
	s = 0
	for i in a:
		s += i
	return s
(n, T) = map(int, input().split())
a = list(map(int, input().split()))
sum = sum(a)
k = 0
k += n * (T // sum)
T %= sum
new_a = []
new_sum = 0
ch = True
while ch:
	for i in range(n):
		if a[i] <= T:
			new_a.append(a[i])
			new_sum += a[i]
			k += 1
			T -= a[i]
	n = len(new_a)
	if n == 0:
		ch = False
		break
	sum = new_sum
	a = new_a
	new_a = []
	new_sum = 0
	k += n * (T // sum)
	T %= sum
print(k)