Ivar the Boneless is a great leader. He is trying to capture Kattegat from Lagertha. The war has begun and wave after wave Ivar's warriors are falling in battle.

Ivar has $n$ warriors, he places them on a straight line in front of the main gate, in a way that the $i$-th warrior stands right after $(i-1)$-th warrior. The first warrior leads the attack.

Each attacker can take up to $a_i$ arrows before he falls to the ground, where $a_i$ is the $i$-th warrior's strength.

Lagertha orders her warriors to shoot $k_i$ arrows during the $i$-th minute, the arrows one by one hit the first still standing warrior. After all Ivar's warriors fall and all the currently flying arrows fly by, Thor smashes his hammer and all Ivar's warriors get their previous strengths back and stand up to fight again. In other words, if all warriors die in minute $t$, they will all be standing to fight at the end of minute $t$.

The battle will last for $q$ minutes, after each minute you should tell Ivar what is the number of his standing warriors.


-----Input-----

The first line contains two integers $n$ and $q$ ($1 \le n, q \leq 200\,000$) — the number of warriors and the number of minutes in the battle.

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \leq a_i \leq 10^9$) that represent the warriors' strengths.

The third line contains $q$ integers $k_1, k_2, \ldots, k_q$ ($1 \leq k_i \leq 10^{14}$), the $i$-th of them represents Lagertha's order at the $i$-th minute: $k_i$ arrows will attack the warriors.


-----Output-----

Output $q$ lines, the $i$-th of them is the number of standing warriors after the $i$-th minute.


-----Examples-----
Input
5 5
1 2 1 2 1
3 10 1 1 1

Output
3
5
4
4
3

Input
4 4
1 2 3 4
9 1 10 6

Output
1
4
4
1



-----Note-----

In the first example:   after the 1-st minute, the 1-st and 2-nd warriors die.  after the 2-nd minute all warriors die (and all arrows left over are wasted), then they will be revived thus answer is 5 — all warriors are alive.  after the 3-rd minute, the 1-st warrior dies.  after the 4-th minute, the 2-nd warrior takes a hit and his strength decreases by 1.  after the 5-th minute, the 2-nd warrior dies.

Source: codeforces | Difficulty: MEDIUM
Tags: Sorting


Solutions:
from sys import stdin
from itertools import accumulate

def arr_inp(n):
	if n == 1:
		return [int(x) for x in stdin.readline().split()]
	elif n == 2:
		return [float(x) for x in stdin.readline().split()]
	else:
		return list(stdin.readline()[:-1])

def arr_sum(arr):
	arr.insert(0, 0)
	return list(accumulate(arr, lambda x, y: x + y))

def bs(be, en, x, arr):
	ix = be
	while be < en:
		mid = (be + en) // 2
		val = arr[mid] - arr[ix]
		if val == x:
			return mid
		elif val > x:
			en = mid
		else:
			be = mid + 1
	return en
(n, q) = arr_inp(1)
(a, k) = [arr_inp(1) for i in range(2)]
(cum, ix, ext) = (arr_sum(a), 0, 0)
for i in range(q):
	if ext > k[i]:
		print(n - ix + 1)
		ext -= k[i]
	elif ext == k[i]:
		ext = 0
		if ix >= n:
			ix = 0
		print(n - ix)
	else:
		k[i] -= ext
		ext = 0
		nx = bs(ix, n, k[i], cum)
		if cum[nx] - cum[ix] <= k[i]:
			if nx >= n:
				ix = 0
				nx = 0
			print(n - nx)
		else:
			ext = cum[nx] - cum[ix] - k[i]
			print(n - nx + 1)
		ix = nx


(n, q) = map(int, input().split())
a = list(map(int, input().split()))
k = list(map(int, input().split()))
for i in range(1, n):
	a[i] += a[i - 1]

def binary_search(curr):
	(l, r) = (0, n - 1)
	while l <= r:
		mid = l + r >> 1
		if a[mid] >= curr:
			r = mid - 1
		else:
			l = mid + 1
	return l
res = ''
curr = 0
for i in k:
	curr += i
	if curr >= a[n - 1]:
		res += str(n) + '\n'
		curr = 0
	else:
		it = binary_search(curr)
		res += str(n - it - (a[it] == curr)) + '\n'
print(res)


from itertools import accumulate
from bisect import bisect_right
import sys
(n, q) = map(int, sys.stdin.readline().split())
a = list(map(int, sys.stdin.readline().split()))
k = list(map(int, sys.stdin.readline().split()))
s = list(accumulate(a))
sofar = 0
for x in k:
	sofar += x
	if sofar >= s[-1]:
		sofar = 0
	sys.stdout.write(str(n - bisect_right(s, sofar)) + '\n')


import heapq
from bisect import bisect_left, bisect_right
from collections import Counter
from collections import OrderedDict
from collections import deque
from itertools import accumulate, product
import math
R = lambda : map(int, input().split())
(n, q) = R()
(arr, arrows) = (list(accumulate(R())), list(R()))
cnt = 0
for t in range(q):
	cnt += arrows[t]
	i = bisect_right(arr, cnt)
	if i < n:
		print(n - i)
	else:
		print(n)
		cnt = 0


(n, q) = map(int, input().split())
strength = [0]
for x in map(int, input().split()):
	strength.append(strength[-1] + x)
arrows = list(map(int, input().split()))
fallen = 0
standing = n
for i in range(q):
	ans = -1
	l = 1
	r = n
	while l <= r:
		mid = l + (r - l) // 2
		if strength[mid] - fallen - arrows[i] > 0:
			ans = mid
			r = mid - 1
		else:
			l = mid + 1
	if ans == -1:
		fallen = 0
		print(n)
	else:
		fallen += arrows[i]
		print(n - ans + 1)


(n, q) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
K = [int(i) for i in input().split()]
A = a[:]
for i in range(1, n):
	A[i] += A[i - 1]

def bs(A, key):
	(lo, hi) = (0, len(A) - 1)
	while lo <= hi:
		mid = (lo + hi) // 2
		if A[mid] == key:
			return mid
		elif key < A[mid]:
			hi = mid - 1
		elif A[mid] < key:
			lo = mid + 1
	return hi
D = 0
for i in range(q):
	D += K[i]
	j = bs(A, D)
	if j == n - 1:
		D = 0
		j = -1
	print(n - (j + 1))


from itertools import accumulate
from bisect import bisect
(n, q) = map(int, input().split())
a = list(map(int, input().split()))
k = map(int, input().split())
l = list(accumulate(a))
d = 0
for i in range(q):
	d += next(k)
	ind = bisect(l, d)
	if ind == n:
		d = 0
		ind = 0
	print(n - ind)


from math import *
from bisect import *
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
for _ in range(1):
	(n, q) = M()
	a = LI()
	b = LI()
	c = 0
	d = []
	for i in range(n):
		c += a[i]
		d += [c]
	c = d[-1]
	e = 0
	for i in range(q):
		e += b[i]
		if e >= c:
			print(n)
			e = 0
		else:
			print(n - bisect_right(d, e))


import bisect
(n, q) = map(int, input().split())
health = list(map(int, input().split()))
cuHealth = []
su = 0
for i in health:
	su += i
	cuHealth.append(su)
total = cuHealth[-1]
prev = 0
for arr in map(int, input().split()):
	if arr + prev >= total:
		prev = 0
		print(n)
		continue
	index = bisect.bisect(cuHealth, prev + arr)
	prev += arr
	print(n - index)


from bisect import bisect as bs
from itertools import accumulate as ac
rd = lambda : map(int, input().split())
(n, q) = rd()
(A, k) = (rd(), rd())
a = list(ac(A))
wtf = 0
for i in range(q):
	wtf += next(k)
	j = bs(a, wtf)
	if j == n:
		wtf = 0
		j = 0
	print(n - j)


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

def p(c_k, r):
	l = 0
	while r - l > 1:
		z = (r + l) // 2
		if pr_a[z] > c_k:
			r = z
		else:
			l = z
	return l
pr_a = []
for i in range(n):
	pr_a.append(a[i])
	if i > 0:
		pr_a[i] += pr_a[i - 1]
k = list(map(int, input().split(' ')))
c_k = 0
ans = []
for qq in range(q):
	c_k += k[qq]
	l = p(c_k, n - 1)
	if pr_a[l] <= c_k:
		l += 1
	if c_k >= pr_a[n - 1]:
		c_k = 0
		l = 0
	ans.append(str(n - l))
print('\n'.join(ans))


def search(arr, low, high, val):
	while low <= high:
		mid = low + (high - low) // 2
		if arr[mid] >= val:
			high = mid - 1
		else:
			low = mid + 1
	return low
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
q = list(map(int, input().split()))
for i in range(1, len(l)):
	l[i] += l[i - 1]
val = 0
k = l[-1]
(a, b) = (min(l), max(l))
for i in q:
	val += i
	if val >= l[-1]:
		print(n)
		val = 0
	else:
		pos = search(l, 0, len(l) - 1, val)
		if l[pos] == val:
			print(n - pos - 1)
		else:
			print(n - pos)


def binarySearch(power, arr):
	(low, high) = (0, len(arr) - 1)
	ans = -1
	while low <= high:
		mid = (low + high) // 2
		if arr[mid] <= power:
			ans = mid
			low = mid + 1
		else:
			high = mid - 1
	return ans
(n, q) = map(int, input().split())
arr = list(map(int, input().split()))
k = list(map(int, input().split()))
for i in range(1, n):
	arr[i] += arr[i - 1]
power = 0
for i in range(q):
	power += k[i]
	index = binarySearch(power, arr)
	if index == n - 1:
		print(n)
		power = 0
	elif index == -1:
		print(n)
	else:
		print(n - index - 1)


import sys
import math
MAXNUM = math.inf
MINNUM = -1 * math.inf
ASCIILOWER = 97
ASCIIUPPER = 65

def getInt():
	return int(sys.stdin.readline().rstrip())

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

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

def printOutput(ans):
	sys.stdout.write()
	pass

def binsearch(strlist, health):
	l = 0
	r = len(strlist) - 1
	ans = None
	while l <= r:
		m = (l + r) // 2
		if strlist[m][0] <= health:
			ans = m
			l = m + 1
		else:
			r = m - 1
	return strlist[ans][1]

def solve(n, q, strengths, orders):
	totalstrength = sum(strengths)
	curs = totalstrength
	strlist = [(totalstrength - strengths[0] + 1, len(strengths))]
	for i in range(1, len(strengths)):
		strlist.append((strlist[-1][0] - strengths[i], strlist[-1][1] - 1))
	strlist.sort()
	health = totalstrength
	for q in orders:
		health -= q
		if health <= 0:
			health = totalstrength
			print(n)
		else:
			print(binsearch(strlist, health))

def readinput():
	(n, q) = getInts()
	strengths = list(getInts())
	orders = list(getInts())
	solve(n, q, strengths, orders)
readinput()


def find(num):
	l = 0
	r = n - 1
	while l < r:
		mid = l + r >> 1
		if a[mid] > num:
			r = mid
		else:
			l = mid + 1
	return l
(n, tes) = map(int, input().split())
a = list(map(int, input().split()))
c = list(map(int, a))
b = list(map(int, input().split()))
for i in range(1, n):
	a[i] += a[i - 1]
now = 0
for i in b:
	if i + now >= a[n - 1]:
		print(n)
		now = 0
		continue
	now += i
	print(n - find(now))


def binarySearchCount(arr, n, key):
	left = 0
	right = n
	mid = 0
	while left < right:
		mid = (right + left) // 2
		if arr[mid] == key:
			while mid + 1 < n and arr[mid + 1] == key:
				mid += 1
			break
		elif arr[mid] > key:
			right = mid
		else:
			left = mid + 1
	while mid > -1 and arr[mid] > key:
		mid -= 1
	return mid + 1
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(1, n):
	a[i] += a[i - 1]
res = 0
for i in range(k):
	res += b[i]
	if a[n - 1] <= res:
		res = 0
		print(n)
	else:
		count = binarySearchCount(a, n, res)
		print(n - count)


from bisect import bisect_right
(n, q) = map(int, input().split())
a = [int(X) for X in input().split()]
k = [int(x) for x in input().split()]
for i in range(1, n):
	a[i] += a[i - 1]
an = 0
for j in k:
	j += an
	x = bisect_right(a, j)
	if x == n:
		print(n)
		an = 0
	else:
		print(n - x)
		an = j


def Solution(N, Q, wariors_strength, arrows):
	prefix_sum = [0]
	for strength in wariors_strength:
		prefix_sum.append(prefix_sum[-1] + strength)
	prefix_sum.pop(0)
	arrow_so_far = 0
	for arrow in arrows:
		arrow_so_far += arrow
		if arrow_so_far >= prefix_sum[-1]:
			print(N)
			arrow_so_far = 0
		else:
			idx = binarySearch_LowerBound(prefix_sum, arrow_so_far)
			print(N - idx)

def binarySearch_LowerBound(arr, key):
	l = 0
	r = len(arr) - 1
	while l <= r:
		mid = (l + r) // 2
		if arr[mid] == key:
			return mid + 1
		elif arr[mid] > key:
			r = mid - 1
		else:
			l = mid + 1
	return r + 1
(N, Q) = map(int, input().split())
wariors_strength = list(map(int, input().split()))
arrows = list(map(int, input().split()))
Solution(N, Q, wariors_strength, arrows)


from sys import stdin, stdout
import bisect
input = stdin.readline
t = 1
for _ in range(t):
	(n, q) = map(int, input().split())
	a = [int(x) for x in input().split()]
	pre = []
	s = 0
	for i in a:
		s += i
		pre.append(s)
	lost = 0
	val_lost = 0
	ans = []
	qu = [int(x) for x in input().split()]
	for i in qu:
		val = i + val_lost
		b = bisect.bisect_left(pre, val, lost, n)
		val_lost = min(val, pre[-1])
		if b == n:
			lost = 0
			val_lost = 0
			ans.append(n)
			continue
		if pre[b] == val:
			lost = b + 1
		else:
			lost = b
		if lost == n:
			lost = 0
			val_lost = 0
		ans.append(n - lost)
	for i in ans:
		print(i)


from bisect import bisect as bs
(n, q) = map(int, input().split())
a = list(map(int, input().split()))
k = list(map(int, input().split()))
tmp = 0
sumA = []
for i in range(n):
	tmp += a[i]
	sumA.append(tmp)

def bin_search(left, right, v):
	mid = left + right >> 1
	if left > right:
		return left
	if sumA[mid] == v:
		return mid + 1
	elif sumA[mid] < v:
		return bin_search(mid + 1, right, v)
	else:
		return bin_search(left, mid - 1, v)

def bin_sea_while(lo, hi, x):
	while lo < hi:
		mid = lo + hi >> 1
		if x < sumA[mid]:
			hi = mid
		else:
			lo = mid + 1
	return lo
now = 0
ansList = []
for i in range(q):
	now += k[i]
	ans_id = bin_sea_while(0, n, now)
	if ans_id == n:
		now = 0
		ans_id = 0
	ansList.append(n - ans_id)
print('\n'.join(map(str, ansList)))


(no_of_warrior, no_of_minutes) = map(int, input().split())
li1 = list(map(int, input().split()))
li2 = list(map(int, input().split()))
for j in range(1, no_of_warrior):
	li1[j] = li1[j] + li1[j - 1]
key = 0
d = 0
for key in li2:
	d = d + key
	l = 0
	h = no_of_warrior
	while h - l > 1:
		mid = (l + h) // 2
		if li1[mid] > d:
			h = mid
		else:
			l = mid
	ans = no_of_warrior - l - 1
	if l == 0:
		if li1[l] > d:
			ans = no_of_warrior
		if ans == 0:
			ans = no_of_warrior
	elif ans == 0:
		ans = no_of_warrior
		d = 0
	print(ans)


import bisect
[n, q] = map(int, input().strip().split())
ais = list(map(int, input().strip().split()))
kis = list(map(int, input().strip().split()))
iais = [0 for _ in range(n + 1)]
for i in range(n):
	iais[i + 1] = iais[i] + ais[i]
s = 0
tot = iais[-1]
r = 0
for k in kis:
	s += k
	if s >= tot:
		print(n)
		s = 0
		r = 0
	else:
		r = bisect.bisect_right(iais, s, r) - 1
		print(n - r)


from bisect import bisect_right
(n, q) = list(map(int, input().split()))
a = list(map(int, input().split()))
k = list(map(int, input().split()))
c = []
cnt = 0
for i in range(n):
	cnt += a[i]
	c.append(cnt)
b = a
now = 0
i = 0
for k0 in k:
	now += k0
	if now >= c[-1]:
		now = 0
		print(n)
	else:
		ind = bisect_right(c, now)
		print(n - ind)


import sys
import os.path
if os.path.exists('input_file.txt'):
	sys.stdin = open('input_file.txt', 'r')
	sys.stdout = open('output_file.txt', 'w')

def u_bound(j, n, pre):
	l = 0
	r = n - 1
	while r >= l:
		mid = (l + r) // 2
		if pre[mid] == j:
			return n - mid - 1
		elif pre[mid] < j:
			l = mid + 1
		else:
			r = mid - 1
	return n - r - 1

def main():
	(n, q) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = sum(a)
	c = 0
	pre = [a[0]]
	for i in a[1:]:
		pre.append(pre[-1] + i)
	for j in b:
		c += j
		if c >= pre[-1]:
			print(n)
			c = 0
		else:
			print(u_bound(c, n, pre))
main()


def findFirstGreaterOrEqual(nums, target):
	lo = int(0)
	hi = int(len(nums) - 1)
	if target >= nums[hi]:
		return hi
	while lo < hi:
		mid = int((lo + hi) / 2)
		if target <= nums[mid]:
			hi = mid
		else:
			lo = mid + 1
	return lo
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
q = list(map(int, input().split()))
for i in range(1, n):
	a[i] = a[i - 1] + a[i]
a_copy = a[:]
arrows = 0
for i in range(0, k):
	arrows = arrows + q[i]
	index = findFirstGreaterOrEqual(a_copy, arrows)
	if a_copy[index] > arrows:
		print(len(a_copy) - index)
	elif a_copy[index] <= arrows:
		if index == len(a_copy) - 1:
			print(len(a_copy))
			arrows = 0
		else:
			print(len(a_copy) - index - 1)


import bisect
(n, q) = map(int, input().split())
strenght = [i for i in map(int, input().split())]
arrows = [i for i in map(int, input().split())]
cumul = []
s = 0
for i in strenght:
	s += i
	cumul.append(s)
damage = 0
for j in arrows:
	damage += j
	if damage >= cumul[n - 1]:
		damage = 0
		print(n, end='\n')
	else:
		i = bisect.bisect(cumul, damage)
		print(n - i, end='\n')


(n, k) = map(int, input().split())
lis = list(map(int, input().split()))
ans = [0] * n
ans[0] = lis[0]
for i in range(1, n):
	ans[i] = ans[i - 1] + lis[i]
kk = list(map(int, input().split()))
dec = 0
for i in range(k):
	aro = kk[i]
	l = 0
	r = n - 1
	while l <= r:
		mid = l + (r - l) // 2
		if ans[mid] - dec <= aro:
			l = mid + 1
		else:
			r = mid - 1
	if r == n - 1:
		print(n)
		dec = 0
	else:
		print(n - r - 1)
		dec += aro


from sys import stdin, stdout
import bisect
(n, q) = [int(x) for x in stdin.readline().split()]
a = [int(x) for x in stdin.readline().split()]
k = [int(x) for x in stdin.readline().split()]
acc = 0

def lw(acc):
	global a, n
	pos = bisect.bisect_left(a, acc)
	if pos == n:
		return 0
	if a[pos] == acc:
		if pos + 1 == n:
			return 0
		return pos + 1
	return pos
for i in range(1, n):
	a[i] += a[i - 1]
for i in range(0, q):
	acc += k[i]
	stdout.write(str(n - lw(acc)) + '\n')
	if acc >= a[-1]:
		acc = 0


(n, q) = list(map(int, input().split()))
soldiers = list(map(int, input().split()))
arrows = list(map(int, input().split()))
soldier_sum = [0]
for soldier in soldiers:
	soldier_sum.append(soldier_sum[-1] + soldier)
soldier_sum.append(10 ** 16)
current_pos = 1
damage_carried_over = 0
for arrow in arrows:
	arrow += damage_carried_over
	(l, r) = (current_pos, len(soldier_sum) - 1)
	res = None
	while l <= r:
		mid = (l + r) // 2
		if soldier_sum[mid] - soldier_sum[current_pos - 1] > arrow:
			res = mid
			r = mid - 1
		else:
			l = mid + 1
	damage_carried_over = arrow - (soldier_sum[res - 1] - soldier_sum[current_pos - 1])
	current_pos = res
	if current_pos == len(soldier_sum) - 1:
		current_pos = 1
		damage_carried_over = 0
	print(len(soldiers) + 1 - current_pos)


import bisect

def bin_search(arr, target):
	l = -1
	N = len(arr)
	r = N
	while r - l > 1:
		mid = (r + l) // 2
		mid_el = arr[mid]
		if mid_el > target:
			r = mid
		else:
			l = mid
	return r
(N, times) = list(map(int, input().split()))
line = input()
arr = list(map(int, line.split()))
cum_sum = 0
for i in range(len(arr)):
	tmp = arr[i]
	arr[i] += cum_sum
	cum_sum += tmp
line = input()
attack_arr = list(map(int, line.split()))
prev_d = 0
for d in attack_arr:
	prev_d += d
	ind = bisect.bisect_right(arr, prev_d)
	if ind == N:
		prev_d = 0
		print(N)
	else:
		print(N - ind)


import os
from string import *
from math import *
from itertools import *
from collections import *
from re import *
from sys import *
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')
(stdin, stdout) = (IOWrapper(stdin), IOWrapper(stdout))
input = lambda : stdin.readline().rstrip('\r\n')

def binary_search(p, i):
	if z[-1] - p <= i:
		print(a)
		return 0
	(lo, hi, ans) = (0, a, 0)
	while lo <= hi:
		mid = (lo + hi) // 2
		if z[mid] - p < i:
			lo = mid + 1
		elif z[mid] - p > i:
			hi = mid - 1
			ans = mid - 1
		elif z[mid] - p == i:
			ans = mid
			break
		else:
			break
	p += i
	print(a - ans)
	return p
(a, b) = map(int, input().split())
z = [0]
p = 0
for i in map(int, input().split()):
	z += [z[-1] + i]
for i in map(int, input().split()):
	p = binary_search(p, i)


import bisect
(n, q) = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]
k = [int(s) for s in input().split()]
ac = []
for i in range(len(a)):
	if i == 0:
		ac.append(a[i])
	else:
		ac.append(a[i] + ac[i - 1])
kc = 0
prevpos = -1
for i in range(len(k)):
	kc += k[i]
	pos = bisect.bisect_right(ac, kc, max(prevpos, 0)) - 1
	if pos >= n - 1:
		kc = 0
		pos = -1
	print(n - 1 - pos)
	prevpos = pos


import bisect
(n, q) = list(map(int, input().split()))
warrior = list(map(int, input().split()))
attacker = list(map(int, input().split()))
warriors_new = []
sm = 0
for i in warrior:
	sm += i
	warriors_new.append(sm)
query = 0
ans = 0
for i in attacker:
	query += i
	if query >= warriors_new[n - 1]:
		query = 0
		ans = 0
	else:
		ans = bisect.bisect_right(warriors_new, query, ans)
	print(n - ans)


import bisect

def find_ge(a, key):
	i = bisect.bisect_left(a, key)
	if i == len(a):
		return -1
	return i
(n, q) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
k = [int(x) for x in input().split()]
result = [0] * (q + 1)
result[0] = n
s = [0] * n
s[0] = a[0]
for i in range(1, n):
	s[i] = s[i - 1] + a[i]
remain = 0
attack = 0
for i in range(1, q + 1):
	attack += k[i - 1]
	ge = find_ge(s, attack)
	if ge >= 0:
		remain = s[ge] - attack
		if remain > 0:
			result[i] = n - ge
		else:
			result[i] = n - ge - 1
		if result[i] == 0:
			result[i] = n
			attack = 0
	else:
		result[i] = n
		attack = 0
		remain = 0
print('\n'.join((str(x) for x in result[1:])))


from bisect import bisect_right as br
(n, q) = map(int, input().split())
stn = list(map(int, input().split()))
arro = list(map(int, input().split()))
cum = []
s = 0
for i in range(n):
	s += stn[i]
	cum.append(s)
s1 = 0
ans = 0
for i in range(q):
	if ans == 0:
		s1 = arro[i]
	else:
		s1 += arro[i]
	ind = br(cum, s1)
	ans = n - ind
	if ans == 0:
		print(n)
	else:
		print(ans)


(z, zz) = (input, lambda : list(map(int, z().split())))
(szz, dgraphs, mod) = (lambda : sorted(zz()), {}, 10 ** 9 + 7)
from string import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
(n, m) = zz()
l1 = zz()
l2 = map(int, z().split())
a = list(ac(l1))
d = 0
for i in list(l2):
	d += i
	j = bs(a, d)
	if j == n:
		d = 0
		j = 0
	print(n - j)


(n, q) = map(int, input().split())
a = list(map(int, input().split()))
a.insert(0, 0)
k = list(map(int, input().split()))
(j, g) = (0, 0)
for i in range(1, n + 1):
	a[i] = a[i] + a[i - 1]
while q > 0:
	g = g + k[j]
	(r, l, h) = (-1, 0, n)
	while l <= h:
		m = (l + h) // 2
		if g >= a[m]:
			res = m
			l = m + 1
		else:
			h = m - 1
	if res == n:
		res = 0
		g = 0
	print(n - res)
	j += 1
	q -= 1


from bisect import bisect
(n, q) = map(int, input().split(' '))
strengths = [int(i) for i in input().split(' ')]
arrows = [int(i) for i in input().split(' ')]
sums = [strengths[0]]
for strength in strengths[1:]:
	sums.append(sums[-1] + strength)
current = 0
for arrow in arrows:
	current += arrow
	if current >= sums[-1]:
		current = 0
	print(n - bisect(sums, current))


import os
import sys
from io import BytesIO, IOBase
from collections import Counter
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))

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)

def main():
	(n, q) = map(int, input().split())
	t = list(map(int, input().split()))
	k = list(map(int, input().split()))
	a = [t[0]]
	for i in range(1, n):
		a.append(a[i - 1] + t[i])
	now = 0
	for i in range(q):
		now += k[i]
		if now >= a[n - 1]:
			now = 0
			print(n)
		else:
			l = 0
			r = n - 1
			ans = n
			while l <= r:
				mid = (l + r) // 2
				if now >= a[mid]:
					ans = min(ans, n - 1 - mid)
					l = mid + 1
				else:
					r = mid - 1
			print(ans)
	return
main()


import sys

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

def main():
	(n, q) = map(int, input().split())
	a = list(map(int, input().split()))
	p = [0] * (n + 1)
	for i in range(n):
		p[i + 1] = p[i] + a[i]
	d = 0
	for i in map(int, input().split()):
		l = 0
		r = n + 1
		d += i
		while r - l > 1:
			c = (l + r) // 2
			if p[c] > d:
				r = c
			else:
				l = c
		if l == n:
			d = 0
			l = 0
		print(n - l)
main()


import bisect
(N, Q) = map(int, input().split())
ws = list(map(int, input().split()))
qs = list(map(int, input().split()))
cums = [0]
for w in ws:
	cums.append(cums[-1] + w)
damage = 0
for q in qs:
	damage += q
	if damage >= cums[-1]:
		damage = 0
		print(N)
	else:
		i = bisect.bisect(cums, damage)
		print(N - i + 1)


import sys
import os
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, q) = map(int, input().split())
strength = [0]
for x in map(int, input().split()):
	strength.append(strength[-1] + x)
arrows = list(map(int, input().split()))
fallen = 0
standing = n
final = []
for i in range(q):
	ans = -1
	l = 1
	r = n
	while l <= r:
		mid = l + (r - l) // 2
		if strength[mid] - fallen - arrows[i] > 0:
			ans = mid
			r = mid - 1
		else:
			l = mid + 1
	if ans == -1:
		fallen = 0
		final.append(n)
	else:
		fallen += arrows[i]
		final.append(n - ans + 1)
print(*final, sep='\n')


def bsfg(n, arr, hi=None, lo=0):
	if hi is None:
		hi = len(arr)
	if not arr:
		return None
	mid = (hi + lo) // 2
	if arr[mid] > n >= arr[mid - 1]:
		return mid
	if mid == lo or hi == mid:
		return None
	if arr[mid] > n:
		return bsfg(n, arr, mid, lo)
	return bsfg(n, arr, hi, mid)
(n, q) = map(int, input().split())
sarr = list(map(int, input().split()))
harr = list(map(int, input().split()))
for i in range(1, n):
	sarr[i] += sarr[i - 1]
for i in range(1, q):
	tmp = harr[i] + harr[i - 1]
	harr[i] = tmp if harr[i - 1] < sarr[-1] else harr[i]
for h in harr:
	rez = bsfg(h, sarr)
	print(n - rez if rez else n)


import math
import sys
input = sys.stdin.readline

def get_health(cumsum, l, r):
	res = cumsum[r]
	if l >= 1:
		res -= cumsum[l - 1]
	return res

def main():
	(n, q) = [int(x) for x in input().split(' ')]
	warr = [int(x) for x in input().split(' ')]
	arrow = [int(x) for x in input().split(' ')]
	cumsum = [0 for i in range(n)]
	cumsum[0] = warr[0]
	for i in range(1, n):
		cumsum[i] = warr[i] + cumsum[i - 1]
	start = 0
	minus = 0
	for i in range(q):
		cur_arrows = arrow[i]
		if cur_arrows < warr[start] - minus:
			print(n - start)
			minus += cur_arrows
			continue
		pos = start
		for j in range(25, -1, -1):
			jump = 1 << j
			if pos + jump < n and cur_arrows >= get_health(cumsum, start, pos + jump) - minus:
				pos += jump
		if pos == n - 1:
			start = 0
			minus = 0
			print(n)
		else:
			print(n - pos - 1)
			left = cur_arrows - (get_health(cumsum, start, pos) - minus)
			minus = left
			start = pos + 1
main()


def upper_bound(lst, target):
	l = 0
	r = len(lst) - 1
	res = -1
	while l <= r:
		mid = (l + r) // 2
		if lst[mid] <= target:
			res = mid
			l = mid + 1
		else:
			r = mid - 1
	return res + 1

def main():
	(n, q) = [int(i) for i in input().split()]
	aa = [int(i) for i in input().split()]
	kk = [int(i) for i in input().split()]
	ss = aa
	for i in range(1, n):
		ss[i] += ss[i - 1]
	agg = 0
	for k in kk:
		agg += k
		if agg >= ss[n - 1]:
			agg = 0
			print(n)
			continue
		idx = upper_bound(ss, agg)
		print(n - idx)
main()


import bisect

class WarriorPack:

	def __init__(self, idx___str):
		self.idx___str = idx___str
		self.idx___accum_str = [idx___str[0]]
		for str in idx___str[1:]:
			self.idx___accum_str.append(self.idx___accum_str[-1] + str)
		self.first_alive = 0
		self.alive_nr = len(idx___str)
		self.arrows_since_ressurect = 0

	def tank(self, k):
		self.arrows_since_ressurect += k
		if self.arrows_since_ressurect >= self.idx___accum_str[-1]:
			self.ressurect()
			return self.alive_nr
		self.first_alive = bisect.bisect_right(self.idx___accum_str, self.arrows_since_ressurect)
		self.alive_nr = len(self.idx___str) - self.first_alive
		return self.alive_nr

	def ressurect(self):
		self.first_alive = 0
		self.alive_nr = len(self.idx___str)
		self.arrows_since_ressurect = 0
(warriors_nr, minutes_nr) = (int(x) for x in input().split())
idx___str = tuple((int(x) for x in input().split()))
wp = WarriorPack(idx___str)
minute___arrows_nr = tuple((int(x) for x in input().split()))
for arrows_nr in minute___arrows_nr:
	print(wp.tank(arrows_nr))


from bisect import bisect
(n, q) = map(int, input().split())
a = list(map(int, input().split()))
a.reverse()
s = sum(a)
for i in range(1, n):
	a[i] += a[i - 1]
k = list(map(int, input().split()))
tmp = 0
for i in range(q):
	tmp += k[i]
	if tmp >= s:
		tmp = 0
	print(bisect(a, s - tmp - 1) + 1)


def binarySearch(arr, l, r, x):
	ans = -1
	while l <= r:
		mid = (l + r) // 2
		if arr[mid] > x:
			r = mid - 1
		elif arr[mid] == x:
			ans = mid
			break
		else:
			ans = mid
			l = mid + 1
	return ans
(n, q) = list(map(int, input().split()))
arr = list(map(int, input().split()))
lis = list(map(int, input().split()))
prefix = [arr[0]]
for j in range(1, n):
	prefix.append(prefix[-1] + arr[j])
temp = 0
ans = []
for j in range(q):
	temp2 = lis[j] + temp
	temp1 = binarySearch(prefix, 0, n - 1, temp2)
	if temp1 == n - 1:
		temp = 0
		ans.append(n)
	else:
		temp = arr[temp1]
		temp += temp2 - arr[temp1]
		ans.append(n - temp1 - 1)
for j in range(q):
	print(ans[j])


(n, q) = map(int, input().split())
a = tuple(map(int, input().split()))
k = tuple(map(int, input().split()))
from bisect import *
from itertools import accumulate as ac
ac_a = tuple(ac(a))
allkill = 0
t = []
ap = t.append
for i in ac(k):
	killed = bisect(ac_a, i - allkill)
	if killed == n:
		allkill = i
		ap(n)
	else:
		ap(n - killed)
print('\n'.join(map(str, t)))


import bisect
(n, q) = map(int, input().split())
a = list(map(int, input().split()))
s = [0]
for i in a:
	s.append(s[-1] + i)
k = list(map(int, input().split()))
tb = 0
for i in range(q):
	tb += k[i]
	if tb >= s[-1]:
		tb = 0
		print(n)
	else:
		ans = bisect.bisect_right(s, tb)
		print(n - ans + 1)


from bisect import bisect_left
(n, q) = list(map(int, input().split(' ')))
p = list(map(int, input().split(' ')))
k = list(map(int, input().split(' ')))
x = [0] * (n + 1)
y = [0] * (n + 1)
sum = 0
for i in range(n):
	x[i] = sum
	y[i] = n - i
	sum += p[i]
x[n] = sum
y[n] = 0
att = 0
for i in range(q):
	att += k[i]
	id = bisect_left(x, att + 0.01) - 1
	if y[id] == 0:
		att = 0
		print(n)
	else:
		print(y[id])


from bisect import bisect_left

def bi(a, x):
	i = bisect_left(a, x)
	return i
(n, q) = list(map(int, input().split()))
a = list(map(int, input().split()))
k = list(map(int, input().split()))
b = []
s = 0
for i in range(n):
	s = s + a[i]
	b.append(s)
s = 0
for i in range(q):
	s = s + k[i]
	c = bi(b, s)
	if c == n:
		s = 0
		print(n)
	elif c == n - 1 and b[c] == s:
		s = 0
		print(n)
	elif s == b[c]:
		print(n - c - 1)
	else:
		print(n - c)


from bisect import bisect_right
(n, q) = map(int, input().split())
a = list(map(int, input().split()))
k = list(map(int, input().split()))
for i in range(1, len(a)):
	a[i] += a[i - 1]
fill = 0
for i in range(len(k)):
	fill += k[i]
	idx = bisect_right(a, fill)
	if idx == len(a):
		print(len(a))
		fill = 0
	else:
		print(len(a) - idx)


import bisect

def solve(w, k):
	p_arr = [w[0]]
	for i in range(1, len(w)):
		p_arr.append(p_arr[-1] + w[i])
	damage = 0
	answers = []
	for m in k:
		damage += m
		killed = bisect.bisect_right(p_arr, damage)
		if killed == len(w):
			damage = 0
			killed = 0
		answers.append(len(w) - killed)
	return answers
(n, q) = [int(i) for i in input().strip().split()]
w = [int(i) for i in input().strip().split()]
k = [int(i) for i in input().strip().split()]
res = solve(w, k)
for i in res:
	print(i)


import bisect
from itertools import accumulate
(n, q) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a = list(accumulate(a))
s = 0
b = [int(x) for x in input().split()]
for x in b:
	s += x
	if s >= a[-1]:
		print(n)
		s = 0
	else:
		print(n - bisect.bisect(a, s))


import sys
import math
import bisect
import itertools
(n, q) = list(map(int, sys.stdin.readline().strip().split(' ')))
a = list(map(int, sys.stdin.readline().strip().split(' ')))
prefix_sum = list(itertools.accumulate(a))
k = list(map(int, sys.stdin.readline().strip().split(' ')))
k_sum = 0
for q0 in range(q):
	k_sum += k[q0]
	idx = bisect.bisect_left(prefix_sum, k_sum)
	if idx < n and prefix_sum[idx] == k_sum:
		idx += 1
	if idx == n:
		print(n)
		k_sum = 0
	else:
		print(n - idx)


def bin_ser(arr, curr):
	l = 0
	r = len(arr) - 1
	ans = -1
	while l <= r:
		mid = (l + r) // 2
		if arr[mid] <= curr:
			ans = mid
			l = mid + 1
		else:
			r = mid - 1
	return ans

def main():
	(n, q) = map(int, input().split())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	su = sum(arr)
	curr = 0
	for i in range(1, n):
		arr[i] = arr[i] + arr[i - 1]
	for b in brr:
		curr += b
		pos = n - bin_ser(arr, curr) - 1
		if pos == 0:
			pos = n
		print(pos)
		if curr >= su:
			curr = 0
main()


import bisect as bi
(n, q) = map(int, input().split())
a = list(map(int, input().split()))
l = list(map(int, input().split()))
som = sum(a)
e = 0
p = []
for i in a:
	e += i
	p.append(e)
e = 0
s = set(p)
for i in l:
	e += i
	if e >= som:
		e = 0
	x = bi.bisect(p, e)
	print(n - x)


import bisect
(n, k) = map(int, input().split())
l1 = list(map(int, input().split()))
for i in range(1, len(l1)):
	l1[i] = l1[i - 1] + l1[i]
l2 = list(map(int, input().split()))
sum1 = 0
for i in range(len(l2)):
	sum1 += l2[i]
	p = bisect.bisect_right(l1, sum1)
	if p == n:
		p = 0
		sum1 = 0
	print(n - p)


def binary(li, target, n):
	low = 0
	high = n - 1
	while low < high:
		mid = low + (high - low) // 2
		if li[mid] <= target:
			low = mid + 1
		else:
			high = mid
	return low
(n, q) = map(int, input().split())
power = list(map(int, input().split()))
arrow = list(map(int, input().split()))
p_prefix = [0] * n
a_prefix = [0] * q
p_prefix[0] = power[0]
a_prefix[0] = arrow[0]
last = 0
for i in range(1, n):
	p_prefix[i] = p_prefix[i - 1] + power[i]
for i in range(1, q):
	a_prefix[i] = a_prefix[i - 1] + arrow[i]
for i in range(q):
	if a_prefix[i] - last >= p_prefix[-1]:
		print(n)
		last = a_prefix[i]
	else:
		target = a_prefix[i] - last
		val = binary(p_prefix, target, n)
		print(n - val)


from bisect import *
(n, q) = map(int, input().split())
war = [*map(int, input().split())]
atk = [*map(int, input().split())]
warmap = {war[0]: 1}
wararr = [war[0]]
for i in range(1, n):
	wararr.append(wararr[-1] + war[i])
	warmap[wararr[-1]] = i + 1
nu = 0
for i in atk:
	nu += i
	if nu >= wararr[-1]:
		nu = 0
		print(n)
		continue
	x = bisect_right(wararr, nu) - 1
	if x == -1:
		print(n)
	else:
		print(n - warmap[wararr[x]])


def binary_search(arr, low, high, x):
	if high >= low:
		mid = (high + low) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] > x:
			return binary_search(arr, low, mid - 1, x)
		else:
			return binary_search(arr, mid + 1, high, x)
	else:
		return low
(n, q) = map(int, input().split())
a = list(map(int, input().split()))
k = list(map(int, input().split()))
su = []
su.append(a[0])
bb = []
for i in range(1, n):
	su.append(su[i - 1] + a[i])
pre = 0
for i in range(q):
	ii = binary_search(su, 0, n - 1, pre + k[i])
	if ii == n:
		bb.append(n)
		pre = 0
	elif su[ii] == pre + k[i]:
		if n - 1 - ii == 0:
			bb.append(n)
			pre = 0
		else:
			bb.append(n - 1 - ii)
			pre += k[i]
	else:
		bb.append(n - 1 - ii + 1)
		pre += k[i]
for ele in bb:
	print(ele)


import bisect
(n, q) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
m = 0
for i in a:
	m += i
	c.append(m)
m = 0
for i in range(q):
	k = bisect.bisect_left(c, b[i] + m)
	if k == len(c) or b[i] + m == c[-1]:
		print(n)
		m = 0
		continue
	elif c[k] == b[i] + m:
		m += b[i]
		print(n - k - 1)
	else:
		m += b[i]
		print(n - k)


from bisect import bisect_right, bisect_left
(n, q) = list(map(int, input().split()))
a = list(map(int, input().split()))
for i in range(1, n):
	a[i] += a[i - 1]
k = list(map(int, input().split()))
d = 0
for i in range(q):
	d += k[i]
	if d >= a[-1]:
		d = 0
		print(n)
	else:
		print(n - bisect_right(a, d))


import bisect
[n, q] = list(map(int, input().strip().split()))
ais = list(map(int, input().strip().split()))
kis = list(map(int, input().strip().split()))
iais = [0 for _ in range(n + 1)]
for i in range(n):
	iais[i + 1] = iais[i] + ais[i]

def bsearch(v, xmin, xmax):
	while xmax - xmin > 1:
		xmid = (xmin + xmax) // 2
		if v >= iais[xmid]:
			xmin = xmid
		else:
			xmax = xmid
	return xmin

def lsearch(v, xmin, xmax):
	x = xmin
	while x + 1 < xmax and v >= iais[x + 1]:
		x += 1
	return x
thrs = (iais[-1] // n + 1) * 440
s = 0
tot = iais[-1]
prevr = 0
for k in kis:
	s += k
	if s >= tot:
		print(n)
		s = 0
		prevr = 0
	else:
		r = bisect.bisect_right(iais, s, prevr) - 1
		print(n - r)
		prevr = r


import copy

def sum(a):
	c = list()
	c.append(a[0])
	n = len(a)
	for i in range(n - 1):
		c.append(c[i] + a[i + 1])
	return c

def binaryfind(b, k, a1, a2):
	if a1 + 1 != a2:
		if b[(a1 + a2) // 2] > k:
			return binaryfind(b, k, a1, (a1 + a2) // 2)
		elif b[(a1 + a2) // 2] == k:
			return (a1 + a2) // 2 + 1
		else:
			return binaryfind(b, k, (a1 + a2) // 2, a2)
	elif k >= b[a1]:
		return a1 + 1
	else:
		return a1
j = input().split()
(n, q) = (int(j[0]), int(j[1]))
a = input().split()
for i in range(n):
	a[i] = int(a[i])
suma = sum(a)
savea = a.copy()
allsum = suma[n - 1]
b = input().split()
u = 0
for i in b:
	if int(i) < allsum - u:
		p = binaryfind(suma, int(i) + u, 0, n - 1)
		print(n - p)
		u += int(i)
	else:
		u = 0
		print(n)


from bisect import bisect_right
(N, Q) = map(int, input().split())
A = list(map(int, input().split()))
K = list(map(int, input().split()))
for i in range(1, N):
	A[i] += A[i - 1]
ans = []
plus = 0
for q in range(Q):
	idx = bisect_right(A, K[q] + plus)
	if idx == N:
		ans.append(N)
		plus = 0
	else:
		ans.append(N - idx)
		plus += K[q]
for q in range(Q):
	print(ans[q])


import atexit
import io
import sys
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
import bisect

def main():
	(n, q) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	k = [int(x) for x in input().split()]
	for i in range(n - 1):
		a[i + 1] += a[i]
	t = 0
	for ki in k:
		t += ki
		xx = n - bisect.bisect_right(a, t)
		if xx == 0:
			xx = n
			t = 0
		print(xx)
main()


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
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')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
MOD = 1000000007

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
(n, q) = value()
a = array()
k_Arr = array()
pre = [a[0]]
for i in range(1, n):
	pre.append(pre[-1] + a[i])
killed = 0
for k in k_Arr:
	killed += k
	ind = bisect_right(pre, killed)
	rem = n - ind
	if rem == 0:
		killed = 0
		rem = n
	print(rem, end=' ')


import sys

def bin_ser(arr, curr):
	l = 0
	r = len(arr) - 1
	ans = -1
	while l <= r:
		mid = (l + r) // 2
		if arr[mid] <= curr:
			ans = mid
			l = mid + 1
		else:
			r = mid - 1
	return ans

def main():
	(n, q) = map(int, sys.stdin.readline().strip().split())
	arr = list(map(int, sys.stdin.readline().strip().split()))
	brr = list(map(int, sys.stdin.readline().strip().split()))
	su = sum(arr)
	curr = 0
	for i in range(1, n):
		arr[i] = arr[i] + arr[i - 1]
	for b in brr:
		curr += b
		pos = n - bin_ser(arr, curr) - 1
		if pos == 0:
			pos = n
		print(pos)
		if curr >= su:
			curr = 0
main()


from __future__ import print_function
from collections import Counter, OrderedDict
from itertools import permutations as perm
from fractions import Fraction
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
import math
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(n, q) = gil()
a = gil()
q = gil()
(ans, p) = ([], a[:])
for i in range(1, n):
	p[i] += p[i - 1]
(total, consumed, i) = (sum(a), 0, 0)
for c in q:
	if consumed + c >= total:
		consumed = i = 0
		ans.append(str(n))
		continue
	(l, r) = (i, n - 1)
	while l <= r:
		mid = (l + r) // 2
		if p[mid] - consumed >= c:
			i = mid
			r = mid - 1
		else:
			l = mid + 1
	consumed += c
	if p[i] - consumed == 0:
		i += 1
		i %= n
	ans.append(str(n - i))
print('\n'.join(ans))


import bisect
(n, q) = map(int, input().split())
a = list(map(int, input().split()))
k = list(map(int, input().split()))
pre = [a[0]]
for i in range(1, n):
	pre.append(a[i] + pre[-1])
vl = 0
for i in range(len(k)):
	vl += k[i]
	f = bisect.bisect_right(pre, vl) - 1
	if f == n - 1:
		print(n)
		vl = 0
	else:
		print(n - 1 - f)


from bisect import bisect
(n, t) = map(int, input().split())
a = list(map(int, input().split()))
k = list(map(int, input().split()))
arr = []
s = 0
b = n
for i in a:
	s += i
	arr.append(s)
ar = arr.copy()
s = 0
for i in k:
	s += i
	j = bisect(ar, s)
	if j == n:
		s = 0
		j = 0
	print(n - j)


(n, q) = map(int, input().split())
a = list(map(int, input().split()))
k = list(map(int, input().split()))
(lst, x) = ([], 0)
for i in range(n):
	x += a[i]
	lst.append(x)
res = 0
from bisect import bisect_left
for (i, x) in enumerate(k):
	res += x
	if lst[n - 1] <= res:
		print(n)
		res = 0
	else:
		t = bisect_left(lst, res)
		if lst[t] == res:
			print(n - t - 1)
		else:
			print(n - t)


import math
from bisect import bisect_right
(numWarriors, numMinutes) = map(int, input().split(' '))
warriorsStrength = list(map(int, input().split(' ')))
arrowCount = list(map(int, input().split(' ')))
warriorsSumStrength = [0] * numWarriors
warriorsSumStrength[0] = warriorsStrength[0]

def find_gt(a, x, lo, hi):
	i = bisect_right(a, x, lo, hi)
	if i != len(a):
		return i
	raise ValueError
for i in range(1, numWarriors):
	warriorsSumStrength[i] = warriorsSumStrength[i - 1] + warriorsStrength[i]
currWarrior = 0
currWarriorStrength = warriorsStrength[currWarrior]
for numArrows in arrowCount:
	if currWarriorStrength >= numArrows:
		currWarriorStrength -= numArrows
		if currWarriorStrength == 0:
			currWarrior += 1
			if currWarrior == numWarriors:
				currWarrior = 0
			currWarriorStrength = warriorsStrength[currWarrior]
		print(numWarriors - currWarrior)
		continue
	numArrows -= currWarriorStrength
	if warriorsSumStrength[numWarriors - 1] - warriorsSumStrength[currWarrior] <= numArrows:
		currWarrior = 0
		currWarriorStrength = warriorsStrength[currWarrior]
		print(numWarriors - currWarrior)
		continue
	newWarrior = find_gt(warriorsSumStrength, numArrows + warriorsSumStrength[currWarrior], currWarrior + 1, numWarriors)
	currWarriorStrength = warriorsSumStrength[newWarrior] - warriorsSumStrength[currWarrior] - numArrows
	currWarrior = newWarrior
	print(numWarriors - currWarrior)


def search(arr, power):
	lo = 0
	hi = len(arr) - 1
	ans = -1
	while lo <= hi:
		mid = (lo + hi) // 2
		if arr[mid] <= power:
			ans = mid
			lo = mid + 1
		else:
			hi = mid - 1
	return ans
(n, q) = list(map(int, input().split()))
a = list(map(int, input().split()))
k = list(map(int, input().split()))
for i in range(1, n):
	a[i] += a[i - 1]
power = 0
for i in range(q):
	power += k[i]
	pos = search(a, power)
	if pos == n - 1:
		print(n)
		power = 0
	elif pos == -1:
		print(n)
	else:
		print(n - pos - 1)


(n, q) = map(int, input().split())
a = list(map(int, input().split()))
p = [0] * (n + 1)
for i in range(n):
	p[i + 1] = p[i] + a[i]
d = 0
for i in map(int, input().split()):
	l = 0
	r = n + 1
	d += i
	while r - l > 1:
		c = (l + r) // 2
		if p[c] > d:
			r = c
		else:
			l = c
	if l == n:
		d = 0
		l = 0
	print(n - l)


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from math import sqrt, floor, factorial, gcd, log
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
from math import gcd
from bisect import bisect
input = lambda : sys.stdin.readline().rstrip('\r\n')
read = lambda : list(map(int, input().strip().split(' ')))

def solve():
	(n, q) = read()
	a = read()
	b = read()
	for i in range(1, n):
		a[i] += a[i - 1]
	p = 0
	for i in b:
		p += i
		ind = bisect(a, p)
		if ind == n:
			p = 0
			print(n)
		else:
			print(n - ind)
solve()


import bisect

def lowerBound(a, x):
	index = bisect.bisect_left(a, x)
	if a[index] == x:
		return index
	return index - 1
(n, q) = [int(i) for i in input().split()]
warrriorStrength = [int(i) for i in input().split()]
LagerthaOrder = [int(i) for i in input().split()]
prefixArray = [0] * n
prefixArray[0] = warrriorStrength[0]
for i in range(1, n):
	prefixArray[i] += prefixArray[i - 1] + warrriorStrength[i]
pointer = 0
ans = -1
for arrow in LagerthaOrder:
	pointer += arrow
	index = -1
	if pointer > prefixArray[-1]:
		pointer = 0
		print(n)
		ans = n
	else:
		index = lowerBound(prefixArray, pointer)
		if index == n - 1:
			print(n)
			pointer = 0
			ans = n
		else:
			c = n - 1
			print(c - index)
			ans = c - index


import bisect
(n, q) = map(int, input().split())
(a, k, curA, curK) = ([], [], 0, 0)
for s in input().split():
	curA += int(s)
	a.append(curA)
for s in input().split():
	curK += int(s)
	index = bisect.bisect(a, curK)
	if index == n:
		print(n)
		curK = 0
	else:
		print(n - index)


from itertools import accumulate
from math import inf

def sum(p):
	return h[p] - h[ind] + val

def check(p):
	return sum(p) >= el

def binSearch(a, b):
	(left, right) = (a - 1, b + 1)
	while right - left > 1:
		mid = (left + right) // 2
		if check(mid):
			right = mid
		else:
			left = mid
	return right
(n, q) = map(int, input().split())
a = list(map(int, input().split()))
k = list(map(int, input().split()))
h = [0] + list(accumulate(a)) + [inf]
ind = 1
val = a[0]
ans = list()
for (i, el) in enumerate(k):
	if el < val:
		val -= el
		ans.append(n + 1 - ind)
	elif el == val:
		ind += 1
		if ind == n + 1:
			ind = 1
			val = a[0]
			ans.append(n)
		else:
			val = a[ind - 1]
			ans.append(n + 1 - ind)
	else:
		b = binSearch(ind, n)
		delta = sum(b) - el
		if b == n + 1:
			ans.append(n)
			ind = 1
			val = a[0]
		elif delta == 0:
			ind = b + 1
			if ind == n + 1:
				ind = 1
				val = a[0]
				ans.append(n)
			else:
				val = a[ind - 1]
				ans.append(n + 1 - ind)
		else:
			ind = b
			val = delta
			ans.append(n + 1 - ind)
print('\n'.join(map(str, ans)))


def binarySearch(num):
	global left, right
	while left != right:
		nextIdex = (left + right) // 2
		if power[nextIdex] > num:
			right = nextIdex
		else:
			left = nextIdex + 1
	return right
(n, q) = map(int, input().split())
soldier = list(map(int, input().split()))
minutes = list(map(int, input().split()))
power = []
sumPower = 0
ans = []
for p in soldier:
	sumPower += p
	power.append(sumPower)
sumHit = 0
maxHit = power[-1]
(left, right) = (0, n - 1)
idex = 0
for hit in minutes:
	sumHit += hit
	if sumHit < maxHit:
		(left, right) = (idex, n - 1)
		idex = binarySearch(sumHit)
		ans.append(n - idex)
	else:
		idex = 0
		ans.append(n)
		sumHit = 0
for x in ans:
	print(x)


import bisect, sys
(n, q) = map(int, input().split())
a = list(map(int, sys.stdin.readline().split()))
t = list(map(int, sys.stdin.readline().split()))
for j in range(1, n):
	a[j] = a[j - 1] + a[j]
x = 0
for v in t:
	x = x + v
	if x < a[0]:
		print(n)
	elif x >= a[-1]:
		print(n)
		x = 0
	else:
		m = bisect.bisect(a, x)
		print(n - m)


import bisect
(n, q) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(1, n):
	a[i] += a[i - 1]
surplus = 0
for i in range(q):
	pos = bisect.bisect_right(a, b[i] + surplus)
	if pos >= n:
		pos = 0
		surplus = 0
	else:
		surplus += b[i]
	print(n - pos)


import os, sys, copy
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 ceil
mod = 10 ** 9 + 7
for _ in range(1):
	(n, q) = map(int, input().split())
	strength = list(map(int, input().split()))
	arrow = list(map(int, input().split()))
	prefix_strength = [0] * n
	for i in range(n):
		if i == 0:
			prefix_strength[i] = strength[i]
		else:
			prefix_strength[i] = strength[i] + prefix_strength[i - 1]
	s = 0
	for i in range(q):
		s += arrow[i]
		if s >= prefix_strength[-1]:
			s = 0
			arrow[i] = -1
		elif i - 1 >= 0 and arrow[i - 1] != -1:
			arrow[i] += arrow[i - 1]
	for i in range(q):
		if arrow[i] == -1:
			print(n)
		else:
			s = 0
			e = n - 1
			r = -1
			while s <= e:
				m = s + (e - s) // 2
				if prefix_strength[m] >= arrow[i]:
					r = m
					e = m - 1
				else:
					s = m + 1
			left = prefix_strength[r] - arrow[i]
			if left == 0:
				print(n - (r + 1))
			else:
				print(n - r)


(n, q) = list(map(int, input().split()))
aa = list(map(int, input().split()))
kk = list(map(int, input().split()))
for i in range(1, n):
	aa[i] += aa[i - 1]

def bsearch(v):
	top = n
	bottom = 0
	i = (top + bottom) // 2
	while aa[i] != v:
		if top == bottom:
			return 0
		if aa[i] > v:
			if aa[i - 1] < v:
				return i
			top = i
		elif aa[i] < v:
			if i == n - 1 or aa[i + 1] > v:
				return i + 1
			bottom = i
		i = (top + bottom) // 2
	return i + 1
arrows = 0
for v in kk:
	arrows += v
	if arrows >= aa[n - 1]:
		print(n)
		arrows = 0
	else:
		print(n - bsearch(arrows))


(n, q) = list(map(int, input().strip().split()))
a = list(map(int, input().strip().split()))
k = list(map(int, input().strip().split()))
summ = []
cur = 0
for item in a:
	cur += item
	summ.append(cur)

def find_loc(l, val, r, nums, target):
	l0 = l
	while l < r:
		mid = (l + r) // 2
		cur_add = nums[mid] - nums[l0] + val
		if cur_add <= target:
			l = mid + 1
		else:
			r = mid
	if nums[l] - nums[l0] + val > target:
		return (l, nums[l] - nums[l0] + val - target)
	else:
		return (l + 1, nums[0])
st = 0
cur = summ[0]
for item in k:
	(loc, cur) = find_loc(st, cur, n - 1, summ, item)
	if loc == n:
		print(n)
		st = 0
	else:
		print(n - loc)
		st = loc


import bisect
(n, q) = map(int, input().split())
a = list(map(int, input().split()))
k = list(map(int, input().split()))
sum = 0
sum_arrow = 0
for i in range(n):
	sum += a[i]
	a[i] = sum
for i in range(q):
	sum_arrow += k[i]
	if sum_arrow >= a[-1]:
		print(n)
		sum_arrow = 0
	else:
		x_point = bisect.bisect_right(a, sum_arrow)
		print(n - x_point)


from bisect import bisect_right
from itertools import accumulate
(n, q) = map(int, input().split())
arr = list(accumulate(map(int, input().split())))
orders = list(map(int, input().split()))
fired = 0
for v in orders:
	fired += v
	idx = bisect_right(arr, fired)
	if idx == n:
		print(n)
		fired = 0
	else:
		print(n - idx)


from itertools import accumulate
from bisect import bisect_right
(n, q) = map(int, input().split())
l = [*map(int, input().split())]
pre = [*accumulate(l)]
cur = 0
res = []
for q in map(int, input().split()):
	cur += q
	i = bisect_right(pre, cur)
	if i == n:
		cur = i = 0
	res.append(n - i)
print(*res, sep='\n')


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

def bins(arr, start, end, v):
	(s, e) = (start, end)
	result = -1
	while s < e:
		m = (s + e) // 2
		if arr[m] >= v:
			e = m
		else:
			result = m
			s = m + 1
	return s if a[s] <= v else s - 1
for i in range(1, len(a)):
	a[i] += a[i - 1]
s = 0
result = []
for ki in k:
	s += ki
	standing = n - bins(a, 0, len(a) - 1, s) - 1
	if standing > 0:
		result.append(standing)
	else:
		result.append(n)
	if s >= a[-1]:
		s = 0
print('\n'.join(map(str, result)))


from bisect import bisect_right

def bs(s, x):
	return bisect_right(s, x)
(n, q) = map(int, input().split())
l = list(map(int, input().split()))
k = list(map(int, input().split()))
s = [0]
for i in range(n):
	s.append(s[i] + l[i])
p = 0
for i in range(q):
	x = bs(s, k[i] + p)
	p = p + k[i]
	if x == n + 1:
		print(n)
		p = 0
	else:
		print(n - x + 1)


import bisect
import math
(n, m) = map(int, input().split())
alpha = list(map(int, input().split()))
for i in range(1, len(alpha)):
	alpha[i] += alpha[i - 1]
k = list(map(int, input().split()))
ksum = 0
for ki in k:
	ksum += ki
	i = bisect.bisect_left(alpha, ksum)
	if i < n and alpha[i] == ksum:
		i += 1
	if n == i:
		ksum = 0
		print(n)
	else:
		print(n - i)


import bisect
(w, m) = input().split(' ')
w = int(w)
strengths = list(map(int, input().split()))
arrows = list(map(int, input().split()))
flag = 0
for i in range(1, len(strengths)):
	strengths[i] += strengths[i - 1]
for i in range(0, len(arrows)):
	flag += arrows[i]
	check = bisect.bisect_right(strengths, flag)
	if check == w:
		flag = check = 0
	print(w - check)


import bisect
(n, q) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
k = list(map(int, input().split(' ')))
startHelth = sum(a)
restHelth = startHelth
helths = [0] * n
helths[0] = a[n - 1]
for i in range(1, n):
	helths[i] = helths[i - 1] + a[n - i - 1]
for (_, arrow) in enumerate(k):
	damage = min(restHelth, arrow)
	restHelth -= damage
	if restHelth == 0:
		restHelth = startHelth
		print(n)
	else:
		j = bisect.bisect_left(helths, restHelth)
		print(j + 1)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 15
mod = 10 ** 9 + 7

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

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

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

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def bs(f, mi, ma):
	mm = -1
	while ma > mi:
		mm = (ma + mi) // 2
		if f(mm):
			mi = mm + 1
		else:
			ma = mm
	if f(mm):
		return mm + 1
	return mm

def main():
	(n, q) = LI()
	a = LI()
	k = LI()
	rr = []
	t = [0] * n
	t[0] = a[0]
	for i in range(1, n):
		t[i] = t[i - 1] + a[i]
	cc = 0
	for c in k:
		cc += c

		def f(k):
			return t[k] <= cc
		m = bs(f, 0, n)
		if m == n:
			cc = 0
			rr.append(n)
		else:
			rr.append(n - m)
	return '\n'.join(map(str, rr))
print(main())


def next(A, n, x):
	l = 0
	r = n - 1
	p = -1
	while l <= r:
		m = (l + r) // 2
		if A[m] <= x:
			l = m + 1
		else:
			p = m
			r = m - 1
	return p
(N, Q) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
P = []
P.append(A[0])
for i in range(1, N):
	P.append(P[i - 1] + A[i])
soldiers = P[-1]
arrows = 0
for q in range(Q):
	arrows += B[q]
	if arrows >= soldiers:
		arrows = 0
		print(N)
	else:
		ind = next(P, N, arrows)
		print(N - ind)


import bisect
(n, q) = map(int, input().split())
a = list(map(int, input().split()))
k = list(map(int, input().split()))
for i in range(1, n):
	a[i] += a[i - 1]
numArrows = 0
for val in k:
	numArrows += val
	if numArrows >= a[n - 1]:
		print(n)
		numArrows = 0
	else:
		print(n - bisect.bisect(a, numArrows))


def Low(a, l, r, x):
	while l < r:
		mid = (l + r) // 2
		if a[mid] >= x:
			r = mid
		else:
			l = mid + 1
	if a[l] <= x:
		return l
	else:
		return l - 1
(n, q) = map(int, input().split())
a = list(map(int, input().split()))
k = list(map(int, input().split()))
p = [0] * n
p[0] = a[0]
for i in range(1, n):
	p[i] = p[i - 1] + a[i]
t = 0
for i in range(q):
	t += k[i]
	ans = Low(p, 0, n - 1, t)
	if ans == -1 or ans == n - 1:
		print(n)
	else:
		print(n - ans - 1)
	if ans == n - 1:
		t = 0


import bisect as bis
(n, q) = map(int, input().split())
a = [int(e) for e in input().split()]
k = [int(e) for e in input().split()]
for i in range(1, n):
	a[i] += a[i - 1]
i = 1
while i < q:
	while i < q and k[i - 1] >= a[n - 1]:
		i += 1
	if not i < q:
		break
	k[i] += k[i - 1]
	i += 1
for x in range(q):
	num = bis.bisect(a, k[x])
	if num == n:
		print(n)
	else:
		print(n - num)


(n, q) = map(int, input().split())
hp = list(map(int, input().split()))
a = list(map(int, input().split()))
hh = [0] * n
hh[0] = hp[0]
for i in range(1, n):
	hh[i] = hh[i - 1] + hp[i]
comp = 0
s = []
for x in a:
	comp += x
	high = n
	low = 0
	curr = n // 2
	while True:
		curr = (high + low) // 2
		if curr >= n or abs(high - low) == 1 or hh[curr] == comp:
			break
		if hh[curr] > comp:
			high = curr
		else:
			low = curr
	if curr >= n - 1:
		s.append(n)
		comp = 0
	elif curr == 0 and comp < hh[curr]:
		s.append(n)
	else:
		s.append(n - curr - 1)
print('\n'.join(list(map(str, s))))


(n, q) = map(int, input().split())
a = list(map(int, input().split()))
k = list(map(int, input().split()))
s = a.copy()
for i in range(1, n):
	s[i] = s[i] + s[i - 1]
ans = []
ck = 0
for i in range(q):
	ck += k[i]
	if ck >= s[-1]:
		ans.append(str(n))
		ck = 0
	else:
		l = 0
		h = n - 1
		while l < h:
			m = (l + h) // 2
			if s[m] > ck:
				h = m
			else:
				l = m + 1
		ans.append(str(n - l))
print('\n'.join(ans))


(n, q) = map(int, input().split())
A = list(map(int, input().split()))
K = list(map(int, input().split()))
from itertools import accumulate
C = [0] + A
C = list(accumulate(C))
total = 0
ans = [0] * q
import bisect
for (i, k) in enumerate(K):
	total += k
	j = bisect.bisect_right(C, total)
	if j != n + 1:
		ans[i] = n - (j - 1)
	else:
		ans[i] = n
		total = 0
print(*ans, sep='\n')


import bisect
(n, q) = map(int, input().split())
a = list(map(int, input().split()))
for i in range(1, len(a)):
	a[i] += a[i - 1]
k = list(map(int, input().split()))
ksum = 0
for ki in k:
	ksum += ki
	i = bisect.bisect_left(a, ksum)
	if i < n and a[i] == ksum:
		i += 1
	if n == i:
		ksum = 0
		print(n)
	else:
		print(n - i)


from bisect import bisect
(n, q) = [int(i) for i in input().split()]
s = [int(i) for i in input().split()]
r = [int(i) for i in input().split()] + [0]
u = [0]
for i in s:
	u.append(u[-1] + i)
ans = 0
t = 0
for i in range(q):
	ans = bisect(u, r[i] + t)
	t += r[i]
	if ans == n + 1:
		ans = 1
		t = 0
	print(n - ans + 1)


def lb(arr, val):
	le = 0
	ri = len(arr)
	while le < ri:
		mid = (le + ri) // 2
		if arr[mid] >= val:
			ri = mid
		else:
			le = mid + 1
	return le
(n, q) = map(int, input().split(' '))
war = list(map(int, input().split(' ')))
arr = list(map(int, input().split(' ')))
pre = [war[0]]
for i in range(1, len(war)):
	pre.append(pre[i - 1] + war[i])
totalHeal = pre[-1]
curArrw = 0
for i in range(q):
	curArrw += arr[i]
	if curArrw >= totalHeal:
		print(n)
		curArrw = 0
	else:
		idx = lb(pre, curArrw)
		if pre[idx] - curArrw > 0:
			idx -= 1
		idx += 1
		print(n - idx)


from bisect import bisect_right
(n, q) = map(int, input().split())
l = list(map(int, input().split()))
q = list(map(int, input().split()))
p = [l[0]]
for i in range(1, len(l)):
	p.append(p[-1] + l[i])
a = 0
for i in range(len(q)):
	a += q[i]
	x = bisect_right(p, a)
	if x == n:
		print(n)
		a = 0
	else:
		print(n - x)


import bisect
(n, q) = map(int, input().split())
strength = list(map(int, input().split()))
arrows = list(map(int, input().split()))
for i in range(1, n):
	strength[i] += strength[i - 1]
No_arrows = 0
n -= 1
for i in range(q):
	No_arrows += arrows[i]
	if No_arrows >= strength[-1]:
		No_arrows = 0
		print(n + 1)
	else:
		it = bisect.bisect_left(strength, No_arrows)
		if strength[it] == No_arrows:
			print(n - it)
		else:
			print(n - it + 1)


def main():
	(n, q) = map(int, input().split())
	ans = []
	a = list(map(int, input().split()))
	k = list(map(int, input().split()))
	b = []
	w = 0
	for i in range(n):
		w += a[i]
		b.append(w)
	s = sum(a)
	cur = 0
	for m in range(q):
		cur += k[m]
		if cur >= s:
			cur = 0
		l = -1
		r = n - 1
		while r - l != 1:
			m = (l + r) // 2
			if b[m] > cur:
				r = m
			else:
				l = m
		ans.append(l)
	for i in range(q):
		print(n - 1 - ans[i])
main()


from bisect import bisect_right
(n, q) = map(int, input().split())
a = list(map(int, input().split()))
k = list(map(int, input().split()))
for i in range(1, n):
	a[i] += a[i - 1]
c = 0
for i in k:
	c += i
	t = bisect_right(a, c)
	if n != t:
		print(n - t)
	else:
		print(n)
		c = 0


import sys
from bisect import insort, bisect_right, bisect_left
data = sys.stdin.readlines()
lis = []
for line in data:
	lis.append(line)
(n, q) = map(int, lis[0].split())
fighters = list(map(int, lis[1].split()))
arrows = list(map(int, lis[2].split()))
fighters_cum = [fighters[0]]
for i in range(1, len(fighters)):
	fighters_cum.append(fighters[i] + fighters_cum[i - 1])
l = len(fighters)
arw = 0
for i in range(q):
	arw += arrows[i]
	ind = bisect_right(fighters_cum, arw)
	if ind == l:
		arw = 0
		print(l)
		continue
	print(l - ind)


from bisect import bisect_left
from itertools import accumulate
(n, q) = input().split()
n = int(n)
q = int(q)
a = list(map(int, input().split()))
k = list(map(int, input().split()))
reqArrows = sum(a)
prevArrows = 0
accuA = list(accumulate(a))
accuK = list(accumulate(k))
for i in range(q):
	prevArrows += k[i]
	if prevArrows >= reqArrows:
		print(n)
		prevArrows = 0
	else:
		x = bisect_left(accuA, prevArrows)
		if accuA[x] == prevArrows:
			print(n - x - 1)
		else:
			print(n - x)


import sys
input = lambda : sys.stdin.readline()
MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : list(map(int, input().split()))
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
from itertools import accumulate
from bisect import bisect_right
(n, q) = f()
lstg = list(accumulate(il()))
arrw = list(accumulate(il()))
sm = 0
for i in range(q):
	x = bisect_right(lstg, arrw[i] - sm)
	if x == n:
		print(n)
		sm = arrw[i]
	else:
		print(n - x)


import bisect
from itertools import accumulate
(n, q) = map(int, input().split())
a = map(int, input().split())
s = map(int, input().split())
ac_a = list(accumulate(a))
ac_s = list(accumulate(s))
crazydamage = 0
result = []
for onedamage in ac_s:
	killedp = bisect.bisect(ac_a, onedamage - crazydamage)
	if killedp == n:
		crazydamage = onedamage
		result.append(n)
	else:
		result.append(n - killedp)
print('\n'.join(map(str, result)))


(n, q) = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
k = list(map(int, input().split(' ')))
s = [0]
for i in range(0, n):
	s.append(s[-1] + a[i])
index = 0
damage = 0
for i in range(q):
	if s[n] - s[index] - damage <= k[i]:
		print(n)
		(index, damage) = (0, 0)
		continue
	(lo, hi) = (index, n)
	while hi - lo > 1:
		mid = (lo + hi) // 2
		if s[mid] - s[index] - damage > k[i]:
			hi = mid
		else:
			lo = mid
	damage = k[i] - (s[hi - 1] - s[index] - damage)
	index = hi - 1
	print(n - index)


def STR():
	return list(input())

def INT():
	return int(input())

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

def MAP2():
	return map(float, input().split())

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

def STRING():
	return input()
from heapq import heappop, heappush
from bisect import *
from collections import deque, Counter
from math import *
from itertools import permutations, accumulate
dx = [-1, 1, 0, 0]
dy = [0, 0, 1, -1]

def Binary_Search(arr, x, n):
	(l, r) = (0, n - 1)
	while l <= r:
		mid = l + (r - l) // 2
		if arr[mid] == x:
			return mid + 1
		elif arr[mid] > x:
			r = mid - 1
		else:
			l = mid + 1
	return r + 1
(n, q) = MAP()
a = LIST()
b = LIST()
ps = list(accumulate(a))
ans = []
arrows = 0
for arrow in b:
	arrows += arrow
	if arrows >= ps[-1]:
		ans.append(n)
		arrows = 0
	else:
		res = Binary_Search(ps, arrows, n)
		ans.append(n - res)
for i in ans:
	print(i)


import bisect
(n, q) = [int(v) for v in input().split()]
va = [int(v) for v in input().split()]
vk = [int(v) for v in input().split()]
for i in range(1, n):
	va[i] += va[i - 1]
ans = []
curr = 0
for k in vk:
	curr += k
	it = bisect.bisect_right(va, curr)
	if it == n:
		ans.append(n)
		curr = 0
	else:
		ans.append(n - it)
print('\n'.join((str(v) for v in ans)))