jiahuimbzuai/CoQuIR huggingface dataset:
//  [javascript]
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
 　  tmp0 = input[0].split(" ");
    var A= parseInt(tmp0[0],10);
    var B=  parseInt(tmp0[1],10);
    var M=  parseInt(tmp0[2],10);
  //２行目、３行目を配列としてうけとる
      aList = input[1].split(" ").map(Number);
      bList = input[2].split(" ").map(Number);
  //配列の最小値をたす
     mab=Math.min.apply(null, aList)+Math.min.apply(null, bList);

    for(i=3;i<3+M;i++){
  
      tmp1 = input[i].split(" ");
      var x = parseInt(tmp1[0], 10);
      var y = parseInt(tmp1[1], 10);
      var c = parseInt(tmp1[2], 10);
      var tt=aList[x-1]+bList[y-1]-c;
      if (mab>tt){mab=tt;}
        }
  console.log(mab);
    }
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict"
function main(arg) {
    var data = arg.trim().split("\n")
    var tmp = data.shift().split(" ").map(Number)
    var A = tmp[0]
    var B = tmp[1]
    var M = tmp[2]
    var a = data.shift().split(' ').map(Number)
    var b = data.shift().split(' ').map(Number)
    var min_a = Math.min.apply(null, a);
    var min_b = Math.min.apply(null, b);
    var ans = 0
    for (var i = 0; i < data.length; i++) {
        var row = data[i].split(' ').map(Number)
        var x = row[0]
        var y = row[1]
        var c = row[2]
        var _x = a[x - 1]
        var _y = b[y - 1]
        var d = _x + _y - c
        if (i === 0) {
            ans = d
        }
        // console.log(ans)
        ans = Math.min(ans, d)
    }
    console.log(Math.min(ans, min_a + min_b))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}

//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i, no){
  switch(no){
    case 0: return i;
    case 1: return parseInt(i);
    case 2: return i.split(" ");
    case 3: return i.split("\n");
    case 4: return i.split(" ").map((a)=>Number(a));
    case 5: return i.split("\n").map((a)=>Number(a));
    case 6: return i.split("");
    case 7: return i.split("").map((a)=>Number(a));
  }}

function Main(input) {
  input = myconv(input, 3);
  const A = myconv(input[0], 4)[0];
  const B = myconv(input[0], 4)[1];
  const M = myconv(input[0], 4)[2];
  const list_a = myconv(input[1], 4);
  const list_b = myconv(input[2], 4);
  input.shift();
  input.shift();
  input.shift();

  a = Math.min.apply(null, list_a);
  b = Math.min.apply(null, list_b);
  let m = a + b;

  len = input.length;
  for(let i = 0; i < len; i++){
    let x = myconv(input[i], 4)[0] - 1;
    let y = myconv(input[i], 4)[1] = 1;
    let c = myconv(input[i], 4)[2];
    let deals = a[x] + b[y] - c;

    if (deals < m) {
      m = deals;
    }
  }
  console.log(m);
}
Main(myin());
//  [javascript]
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}

//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i, no){
  switch(no){
    case 0: return i;
    case 1: return parseInt(i);
    case 2: return i.split(" ");
    case 3: return i.split("\n");
    case 4: return i.split(" ").map((a)=>Number(a));
    case 5: return i.split("\n").map((a)=>Number(a));
    case 6: return i.split("");
    case 7: return i.split("").map((a)=>Number(a));
  }}

function Main(input) {
  input = myconv(input, 3);
  const A = myconv(input[0], 4)[0];
  const B = myconv(input[0], 4)[1];
  const M = myconv(input[0], 4)[2];
  const a = myconv(input[1], 4);
  const b = myconv(input[2], 4);
  input.shift();
  input.shift();
  input.shift();
  let price = [];
  for(let i = 0; i < A; i++) {
    for(let j = 0; j < B; j++) {
      let p = a[i] + b[j];
      price.push(p);
    }
  }
  len = input.length;
  for(let i = 0; i < len; i++){
    let x = myconv(input[i], 4)[0];
    let y = myconv(input[i], 4)[1];
    let c = myconv(input[i], 4)[2];

    let k = (x-1)*B + y - 1;
    const origin_p = price[k];
    price.push(price[k] - c);
  }
  console.log(price);
  console.log(Math.min.apply(null, price));
}
Main(myin());
//  [go]
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

const (
	// 初期バッファサイズ
	initialBufSize = 10000
	// バッファサイズの最大値。Scannerは必要に応じこのサイズまでバッファを大きくして各行をスキャンする。
	// この値がinitialBufSize以下の場合、Scannerはバッファの拡張を一切行わず与えられた初期バッファのみを使う。
	maxBufSize = 1000000
)

func main() {

	var wtr = bufio.NewWriter(os.Stdout)
	var sc = bufio.NewScanner(os.Stdin)
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)

	var A, B, M int
	sc.Scan()
	temp := strings.Split(sc.Text(), " ")
	A, _ = strconv.Atoi(temp[0])
	B, _ = strconv.Atoi(temp[1])
	M, _ = strconv.Atoi(temp[2])

	a := make([]int, A)
	b := make([]int, B)

	amin := math.MaxInt64
	bmin := math.MaxInt64

	sc.Scan()
	for i, s := range strings.Split(sc.Text(), " ") {
		a[i], _ = strconv.Atoi(s)
		if a[i] < amin {
			amin = a[i]
		}
	}
	sc.Scan()
	for i, s := range strings.Split(sc.Text(), " ") {
		b[i], _ = strconv.Atoi(s)
		if b[i] < bmin {
			bmin = b[i]
		}
	}

	min := amin + bmin

	for j := 0; j < M; j++ {
		sc.Scan()
		temp := strings.Split(sc.Text(), " ")
		//fmt.Println(temp)
		x, _ := strconv.Atoi(temp[0])
		y, _ := strconv.Atoi(temp[1])
		c, _ := strconv.Atoi(temp[2])
		t := a[x-1] + b[y-1] - c
		if t < min {
			min = t
		}
	}

	fmt.Fprintln(wtr, min)
	_ = wtr.Flush()
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc.Split(bufio.ScanWords)
	a, b, m := nextInt(), nextInt(), nextInt()

	am := int(1e9)
	as := make([]int, a)
	for i := 0; i < a; i++ {
		as[i] = nextInt()
		am = min(am, as[i])
	}

	bm := int(1e9)
	bs := make([]int, b)
	for i := 0; i < b; i++ {
		bs[i] = nextInt()
		bm = min(bm, bs[i])
	}

	ans := am + bm
	for i := 0; i < m; i++ {
		x, y, c := nextInt()-1, nextInt()-1, nextInt()
		ans = min(ans, as[x]+bs[y]-c)
	}
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	a, b, m := scanInt(), scanInt(), scanInt()
	as, bs := make([]int, a), make([]int, b)
	minA, minB := math.MaxInt32, math.MaxInt32
	for i := range as {
		as[i] = scanInt()
		minA = min(minA, as[i])
	}
	for i := range bs {
		bs[i] = scanInt()
		minB = min(minB, bs[i])
	}

	ans := minA + minB
	for i := 0; i < m; i++ {
		x, y, c := scanInt(), scanInt(), scanInt()
		ans = min(ans, as[x-1]+bs[y-1]-c)
	}

	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
//  [go]
package main

import "fmt"

func main() {
	var a, b, m int
	fmt.Scan(&a, &b, &m)

	am := int(1e9)
	as := make([]int, a)
	for i := 0; i < a; i++ {
		fmt.Scan(&as[i])
		am = min(am, as[i])
	}

	bm := int(1e9)
	bs := make([]int, b)
	for i := 0; i < b; i++ {
		fmt.Scan(&bs[i])
		bm = min(bm, bs[i])
	}

	ans := am + bm
	var x, y, c int
	for i := 0; i < m; i++ {
		fmt.Scan(&x, &y, &c)
		x--
		y--
		ans = min(ans, as[x]+bs[y]-c)
	}
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
//  [go]
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, m int
	fmt.Scan(&a, &b, &m)
	as := make([]int, a)
	bs := make([]int, b)
	minA, minB := math.MaxInt32, math.MaxInt32
	for i := range as {
		fmt.Scan(&as[i])
		minA = min(minA, as[i])
	}
	for i := range bs {
		fmt.Scan(&bs[i])
		minB = min(minB, bs[i])
	}
	xs := make([]int, m)
	ys := make([]int, m)
	cs := make([]int, m)
	for i := range xs {
		fmt.Scan(&xs[i], &ys[i], &cs[i])
		xs[i]--
		ys[i]--
	}

	minD := math.MaxInt32
	for i := 0; i < m; i++ {
		minD = min(minD, as[xs[i]]+bs[ys[i]]-cs[i])
	}

	fmt.Println(min(minA+minB, minD))
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {

	var wtr = bufio.NewWriter(os.Stdout)
	var sc = bufio.NewScanner(os.Stdin)
	var A, B, M int
	sc.Scan()
	temp := strings.Split(sc.Text(), " ")
	A, _ = strconv.Atoi(temp[0])
	B, _ = strconv.Atoi(temp[1])
	M, _ = strconv.Atoi(temp[2])

	a := make([]int, A)
	b := make([]int, B)

	amin := math.MaxInt64
	bmin := math.MaxInt64

	sc.Scan()
	for i, s := range strings.Split(sc.Text(), " ") {
		a[i], _ = strconv.Atoi(s)
		if a[i] < amin {
			amin = a[i]
		}
	}
	sc.Scan()
	for i, s := range strings.Split(sc.Text(), " ") {
		b[i], _ = strconv.Atoi(s)
		if b[i] < bmin {
			bmin = b[i]
		}
	}

	min := amin + bmin
	_ = M
	for j := 0; j < M; j++ {
		sc.Scan()
		temp := strings.Split(sc.Text(), " ")
		//_, _ := strconv.Atoi(temp[0])
		//_, _ := strconv.Atoi(temp[1])
		c, _ := strconv.Atoi(temp[2])
		t := a[0] + b[0] - c
		if t < min {
			min = t
		}
	}

	fmt.Fprintln(wtr, min)
	_ = wtr.Flush()
}
//  [ruby]
A, B, M = gets.split.map(&:to_i)

aa = gets.split.map(&:to_i)
bb = gets.split.map(&:to_i)

min = aa.min + bb.min

M.times {
  x, y, c = gets.split.map(&:to_i)
  price = aa[x - 1] + bb[y - 1] - c
  min = price if price < min
}

puts min
//  [ruby]
_,_,m = gets.split.map(&:to_i)
list_a = gets.split.map(&:to_i)
list_b = gets.split.map(&:to_i)
min = list_a.min + list_b.min
m.times do
  ia,ib,d = gets.split.map(&:to_i)
  min = [min,list_a[ia-1] + list_b[ib-1] - d].min
end
puts min
//  [ruby]
a,b,m = gets.chomp.split(' ').map(&:to_i)
a_arr = gets.chomp.split(' ').map(&:to_i)
b_arr = gets.chomp.split(' ').map(&:to_i)
min = a_arr.min + b_arr.min
m.times do
  x,y,c = gets.chomp.split(' ').map(&:to_i)
  if a_arr[x-1] + b_arr[y-1] - c < min
    min = a_arr[x-1] + b_arr[y-1] - c
  end
end
puts min
//  [ruby]
a,b,m = gets.split.map(&:to_i)
list_a = gets.split.map(&:to_i)
list_b = gets.split.map(&:to_i)
discount = []
m.times { discount << gets.split.map(&:to_i) }
min = list_a.min + list_b.min
discount.each do |ia,ib,d|
  min = [min,list_a[ia-1] + list_a[ib-1] - d].min
end
puts min
//  [ruby]
A, B, M = gets.split.map(&:to_i)

aa = gets.split.map(&:to_i)
bb = gets.split.map(&:to_i)

xyc = M.times.inject({}) {|acc, _|
  x, y, c = *gets.split.map(&:to_i)
  acc[x] = {} unless acc[x]
  if acc[x][y]
    acc[x][y] = c if acc[x][y] < c
  else
    acc[x][y] = c
  end
  acc
}

min = 10 ** 5 * 2 + 1

aa.each.with_index {|a, ai|
  bb.each.with_index {|b, bi|
    cost = a + b - (xyc[ai + 1]&.[](bi + 1) || 0)
    min = cost if cost < min
  }
}

puts min
//  [ruby]
A, B, M = gets.split.map(&:to_i)

aa = gets.split.map(&:to_i)
bb = gets.split.map(&:to_i)

xyc = M.times.inject({}) {|acc, _|
  x, y, c = *gets.split.map(&:to_i)
  acc[x] = {} unless acc[x]
  if acc[x][y]
    acc[x][y] = c if c < acc[x][y]
  else
    acc[x][y] = c
  end
  acc
}

min = 10 ** 5 * 2 + 1

aa.each.with_index {|a, ai|
  bb.each.with_index {|b, bi|
    cost = a + b - (xyc[ai + 1]&.[](bi + 1) || 0)
    min = cost if cost < min
  }
}

puts min
//  [rust]
use proconio::input;


fn main() {
    input! {
        a: usize,
        b: usize,
        m: usize,
        va: [i32; a],
        vb: [i32; b],
        x: [[i32; 3]; m]
    }

    let mut ans = 1001001001;

    for i in 0..a {
        for j in 0..b {
            ans = std::cmp::min(ans, va[i] + vb[j]);
        }
    }

    for xi in x {
        let ai = xi[0] as usize;
        let bi = xi[1] as usize;
        let c  = xi[2];
        ans = std::cmp::min(ans, va[ai-1] + vb[bi-1] - c);
    }

    println!("{}", ans);
}
//  [rust]
use std::io::stdin;
use std::cmp::min;

fn main() {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let mut first_line = buf.split_whitespace();
    let _ = first_line.next().unwrap();
    let _ = first_line.next().unwrap();
    let coupon: i32 = first_line.next().unwrap().parse().unwrap();

    buf.clear();
    stdin().read_line(&mut buf).unwrap();
    let type_a = buf.split_whitespace();
    let type_a = type_a.map(|iter| iter.parse::<i32>().unwrap()).collect::<Vec<i32>>();

    buf.clear();
    stdin().read_line(&mut buf).unwrap();
    let type_b = buf.split_whitespace();
    let type_b = type_b.map(|iter| iter.parse::<i32>().unwrap()).collect::<Vec<i32>>();

    let mut coupon_pair = Vec::new();
    for _ in 0..coupon{
        let mut buf = String::new();
        stdin().read_line(&mut buf).unwrap();
        let mut input = buf.split_whitespace();
        let a_index: usize = input.next().unwrap().parse().unwrap();
        let b_index: usize = input.next().unwrap().parse().unwrap();
        let discount: usize = input.next().unwrap().parse().unwrap();
        coupon_pair.push([a_index, b_index, discount]);
    }

    println!("{}", solve(type_a, type_b, coupon_pair));
}

fn solve(type_a: Vec<i32>, type_b: Vec<i32>, coupon_pair: Vec<[usize; 3]>) -> i32{
    let normal_min = type_a.iter().min().unwrap() + type_b.iter().min().unwrap();
    let mut discounts = Vec::with_capacity(coupon_pair.len());
    
    for coupon in coupon_pair{
        let discount: i32 = type_a[coupon[0] - 1] + type_b[coupon[1] - 1] - coupon[2] as i32;
         discounts.push(discount);
    }
    let discount_min = *(discounts.iter().min().unwrap());
    return min(normal_min, discount_min)
}
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// use std::io::{stdout, Write, BufWriter};
use std::cmp::min;

fn main() {
    input! {
        a_size: usize,
        b_size: usize,
        m: usize,
        refg: [i32; a_size],
        mw: [i32; b_size],
        disc: [(usize, usize, i32); m],
    }

    let mut vals: Vec<i32> = vec![];

    for (x, y, c) in disc {
        vals.push(*(refg.get(x - 1).unwrap()) + *(mw.get(y - 1).unwrap()) - c)
    }

    for &a in refg.iter() {
        for &b in mw.iter() {
            vals.push(a + b)
        }
    }

    println!("{}", vals.iter().min().unwrap());
}
//  [swift]
import Foundation

extension String {
    
    func toStrList() -> [String] {
        return self.map{String($0)}
    }
    
    func toIntList() -> [Int] {
        return self.map{Int(String($0))!}
    }
    
    func toSepDoubleList() -> [Double]{
        return self.split(separator: " ").map{Double($0)!}
    }

    func toSepIntList() -> [Int] {
        return self.split(separator: " ").map{Int($0)!}
    }

    func toSepStrList() -> [String] {
        return self.split(separator: " ").map{String($0)}
    }
    
    func zFill(n:Int) -> String {
        return String(format: "%0\(n)d", Int(self)!)
    }
    
    func count(c:Character) -> Int{
        var result = 0

        for e in self{
            if e == c{
                result += 1
            }
        }
        return result
    }

    func counter() -> Dictionary<Character, Int>{
        var result:[Character:Int] = [:]
        
        for c in self{
            guard let _ = result.index(forKey: c) else {
                result[c] = 1
                continue
            }
            result[c]! += 1
        }
        return result
    }
}

extension Int {
    func toBin() -> String {
        return String(self, radix: 2)
    }
    
    func toNBin(_ radix:Int) -> String{
        return String(self, radix: radix)
    }
    
    func toD() -> Double {
        return Double(self)
    }
}

extension Double {
    func toI() -> Int {
        return Int(self)
    }
}

extension Array where Element: Equatable{
    func count(n:Self.Element) -> Int{
        var result = 0
        for e in self{
            if e == n{
                result += 1
            }
        }
        return result
    }
}

func pow(_ base:Int,_ exp:Int) -> Int{
    let d = pow(base.toD(), exp.toD())
    return Int(d)
}

func hitachi2020b() -> Int{
    let ABM = readLine()!.toSepIntList()
    let A = readLine()!.toSepIntList()
    let B = readLine()!.toSepIntList()
    
    var sum = A.min()! + B.min()!
    for _ in 1...ABM[2]{
        let xyc = readLine()!.toSepIntList()
        sum = min(A[xyc[0]-1] + B[xyc[1]-1] - xyc[2], sum)
    }
    return sum
}

print(hitachi2020b())
//  [swift]
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let (A, B, M) = (input[0], input[1], input[2])
let a = readLine()!.characters.split(" ").map{Int(String($0))!}
let b = readLine()!.characters.split(" ").map{Int(String($0))!}
let m = (0..<M).map{_ in readLine()!.characters.split(" ").map{Int(String($0))!}}

var ans = a.minElement()! + b.minElement()!
for i in m {
  ans = min(ans, a[i[0]-1]+b[i[1]-1]-i[2])
}

print(ans)
//  [swift]
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let (A, B, M) = (input[0], input[1], input[2])
let a = readLine()!.characters.split(" ").map{Int(String($0))!}
let b = readLine()!.characters.split(" ").map{Int(String($0))!}
let m = (0..<M).map{_ in readLine()!.characters.split(" ").map{Int(String($0))!}}

var ans = a.minElement()! + b.minElement()!
for i in m {
  ans = min(ans, a[i[0]]+b[i[1]]-i[2])
}

print(ans)
//  [typescript]
function Main(input) {
    const lines = input.split("\n");

    const [A, B, M] = lines.shift().split(' ').map(Number);
    const aList = lines.shift().split(' ').map(Number);
    const bList = lines.shift().split(' ').map(Number);

    const minA = Math.min(...aList);
    const minB = Math.min(...bList);

    let minCost = minA + minB;

    for (let i = 0; i < M; i++) {
        const [x, y, c] = lines[i].split(' ').map(Number);
        minCost = Math.min(minCost, aList[x-1] + bList[y-1] - c);
    }

    console.log(minCost);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
// https://atcoder.jp/contests/hitachi2020
import * as fs from "fs";

const stdin = fs.readFileSync("/dev/stdin", "utf8");
const split = stdin.split("\n");
Main(split);

function Main(inputLines: string[]) {
  const [A, B, M] = inputLines[0].split(" ").map(ele=>Number(ele));
  const a = inputLines[1].split(" ").map(ele=>Number(ele));
  const b = inputLines[2].split(" ").map(ele=>Number(ele));
  let min = 200000;
  for (let i = 3; i < 3 + M; i++) {
    const [x, y, c] = inputLines[i].split(" ").map(ele=>Number(ele));
    const cost = a[x-1] + b[y-1] - c;
    if (min > cost) {
      min = cost;
    }
  }
  const minA = Math.min.apply(null, a);
  const minB = Math.min.apply(null, b);
  if (min > (minA + minB)) {
    console.log(minA + minB);
    return;
  }
  console.log(min);
}
//  [typescript]
import * as fs from 'fs';

namespace AtCoder.hitachi2020 {

    export class Program {
        /**
         * in
         * 2 2 1
         * 3 5
         * 3 5
         * 2 2 2
         * out
         * 6
         */
        static main(inp: string): void {

            // a,bの最安値
            // クーポンを使ったときの値
            const [a, b, m]: number[] = inp.split('\n')[0].split(' ').map(Number);
            const aList: number[] = inp.split('\n')[1].split(' ').map(Number);
            const bList: number[] = inp.split('\n')[2].split(' ').map(Number);

            let ans1: number = 0;
            // ans1 = aList.sort()[0];
            // ans1 += bList.sort()[0];
            ans1 = Math.min(...aList)
            ans1 += Math.min(...bList)
            // ans1 = aList.reduce((a, b) => Math.min(a, b));
            // ans1 += bList.reduce((a, b) => Math.min(a, b));

            // クーポン
            const ww: string[] = inp.split('\n');
            for (let i: number = 0; i < m; i++) {
                const [x, y, c]: number[] = ww[i + 3].split(' ').map(Number);

                let wk: number = aList[x - 1] + bList[y - 1] - c;
                if (ans1 > wk) {
                    ans1 = wk;
                }
            }

            console.log(ans1);

        }
    }
}

AtCoder.hitachi2020.Program.main(fs.readFileSync('/dev/stdin', 'utf8').trim());
//  [typescript]
function Main(input) {
    const lines = input.split("\n");

    const [A, B, M] = lines.shift().split(' ').map(Number);
    const aList = lines.shift().split(' ').map(Number);
    const bList = lines.shift().split(' ').map(Number);

    const minA = Math.min(...aList);
    const minB = Math.min(...bList);

    let minCost = minA + minB;

    const subsetLength = 1000;
    for (let i = 0; i < M; i+=subsetLength) {
        const costsWithCoupon = lines.slice(i, i+subsetLength).map(l => {
            const [x, y, c] = l.split(' ');
            return aList[x-1] + bList[y-1] - c;
        });
        minCost = Math.min(minCost, ...costsWithCoupon);
    }

    console.log(minCost);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
function Main(input) {
    const lines = input.split("\n");

    const [A, B, M] = lines.shift().split(' ').map(Number);
    const aList = lines.shift().split(' ').map(Number);
    const bList = lines.shift().split(' ').map(Number);

    const minA = Math.min(...aList);
    const minB = Math.min(...bList);

    let minCost = minA + minB;

    const subsetLength = 1000;
    for (let i = 0; i < M; i+=subsetLength) {
        minCost = lines.slice(i, i+subsetLength).reduce((acc, l) => {
            const [x, y, c] = l.split(' ').map(Number);
            return Math.min(acc, aList[x-1] + bList[y-1] - c);
        }, minCost);
    }

    console.log(minCost);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
function Main(input) {
    const lines = input.split("\n");

    const [A, B, M] = lines.shift().split(' ').map(Number);
    const aList = lines.shift().split(' ').map(Number);
    const bList = lines.shift().split(' ').map(Number);

    const minA = aList.reduce((acc, current) => Math.min(acc, current), Infinity);
    const minB = bList.reduce((acc, current) => Math.min(acc, current), Infinity);
    let minCost = minA + minB;

    minCost = lines.reduce((acc, l) => {
        const [x, y, c] = l.split(' ').map(Number);
        return Math.min(acc, aList[x-1] + bList[y-1] - c);
    }, minCost);

    console.log(minCost);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [python]
n, x = map(int, input().split())
ls = list(map(int, input().split()))

cur = 0
cnt = 0
for i in range(n):
  if cur <= x:
    cnt += 1
  cur += ls[i]
if cur <= x:
  cnt += 1

print(cnt)
//  [python]
n, x = map(int, input().split())

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

count = 1
d = 0
for i in range(n):
    d = d + l[i]
    if d <= x:
        count += 1

print(count)
//  [python]
import math

N , X = map(int,input().split())
L = list(map(int,input().split()))

now = 0
ans = 1
for i in range(N) :
    now += L[i]
    if now <= X :
        ans += 1
    else :
        break

print(ans)
//  [python]
N,X = map(int,input().split())
l = list(map(int,input().split()))
L = [0] + l
D = [0]
count = 0
for i in range(1,N+2):
    D.append(D[i-1]+L[i-1])
    if D[i]<= X:
        count += 1

print(count + 1)
//  [python]
N,X = map(int,input().split())
l = list(map(int,input().split()))
L = [0] + l
D = [0]
count = 0
for i in range(1,N+2):
    D.append(D[i-1]+L[i-2])
    if D[i]<= X:
        count += 1

print(count + 1)
//  [python]
#ABC130 B

N,X = map(int,input().split())
L = list(map(int,input().split()))
D = [0,L[0]]
count = 0
for i in range(2,N+2):
    D.append(D[i-1]+L[i-2])
for i in range(0,N+2):
    if D[i]<= X:
        count += 1

print(count)
//  [java]
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	private final static int MOD = 1000000007;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		int[] L = new int[N];
		sc.fill(L);

		int count = 1;
		long current = 0;
		for (int i = 0; i < N; i++) {
			current += L[i];
			if (current > X) {
				break;
			}

			count++;
		}

		System.out.println(count);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	private static int add(int a, int b) {
		return (a + b) % MOD;
	}

	private static int sub(int a, int b) {
		return (a - b % MOD) % MOD;
	}

	private static int mul(int a, int b) {
		return ((a % MOD) * (b % MOD)) % MOD;
	}

	public static class Scanner {
		private BufferedInputStream inputStream;
		private StringBuilder buffer = new StringBuilder();

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			int read = skip();
			do {
				buffer.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			String text = buffer.toString();
			buffer.delete(0, buffer.length());

			return text;
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}
//  [java]
import java.util.*;
public class Main {
    Scanner sc = new Scanner(System.in);
    public static void main(String[] args){
        new Main().run();
    }
    void run() {
      int n = sc.nextInt();
      int x = sc.nextInt();
      int[] l = new int[n];
      for(int i = 0; i < n; ++i) {
        l[i] = sc.nextInt();
      }
      
      int a = 0;
      int c = 0;
      for (int j = 0; j < l.length; ++j) {
        if (l[0] > x) break; 
        if (a <= x) c++;
        a = a + l[j];
      }
      System.out.println(c);
    }
}
//  [java]
import java.util.*;
public class Main {
    Scanner sc = new Scanner(System.in);
    public static void main(String[] args){
        new Main().run();
    }
    void run() {
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] l = new int[n];
        for(int i = 0; i < n; i++) {
            l[i] = sc.nextInt();
        }
        int a = 0;
        int c = 0;
        for (int j = 0; j < n; j++) {
            if (a <= x) {
                a += l[j];
                c++;
            }
        }
        System.out.print(c);
    }
}
//  [java]
import java.util.*;
public class Main {
    Scanner sc = new Scanner(System.in);
    public static void main(String[] args){
        new Main().run();
    }
    void run() {
      int n = sc.nextInt();
      int x = sc.nextInt();
      int[] l = new int[n];
      for(int i = 0; i < n; ++i) {
        l[i] = sc.nextInt();
      }
      int a = 0;
      int c = 0;
      for (int j = 0; j < l.length; j++) {
        if (l[0] >= x) {
          break;
        }
      	if (a < x) {
          c++;
      	}
        a = a + l[j];
      }
      System.out.println(c);
    }
}
//  [cpp]
#include<stdio.h>
int main(void){
  int n,x,i,t=0;
  scanf("%d %d",&n,&x);
  int l[n];
  for(i=0;i<n;i++){
    scanf("%d",&l[i]);
  }
  i=1;
  while(t<=x && i<=n){
    t+=l[i-1];
    i++;
  }
  if(t>x){
    i--;
  }
  printf("%d\n",i);
  return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  ll n,x;cin>>n>>x;
  vector<ll>a(n);
  for(i=0;i<n;i++)cin>>a[i];
  res=1;buf=0;
  for(i=0;i<n;i++){
    buf+=a[i];
    if(buf<=x)res++;
  }
  cout<<res<<endl;


  return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void solve(long long N, long long X, std::vector<long long> L) {
  ll d = 0;
  ll ans = 1;
  for(int i = 0 ; i < N ; i++){
    d += L[i];
    if( d <= X ){
      ans++;
    }
  }
  cout << ans << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long X;
  scanf("%lld", &X);
  std::vector<long long> L(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &L[i]);
  }
  solve(N, X, std::move(L));
  return 0;
}
//  [cpp]
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

int main(){
	ll N, X;
	cin >> N >> X;
	vector<ll> L(N);
	rep(i, N) cin >> L[i];

	ll ans = 0;
	ll cur = 0;
	for(ll i = 0; i < N; i++) {
		if(cur <= X) {
		ans++;
		}
		cur += L[i];
	}
	cout << ans << endl;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
const long long INF = 1LL << 60;
int main(){
    int N,X;
    cin>>N>>X;
    vector<int>L(N);
    int ans=0;
    int cnt=0;
    rep(i,N){
        cnt++;
        cin>>L[i];
        ans+=L[i];
        if(X<ans){
            cout<<cnt<<endl;
            break;
        }
    }
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
const long long INF = 1LL << 60;
int main(){
    int N,X;
    cin>>N>>X;
    vector<int>L(N);
    int ans=0;
    int cnt=0;
    rep(i,N){
        cnt++;
        cin>>L[i];
        ans+=L[i];
        if(X<=ans){
            cout<<cnt<<endl;
            break;
        }
    }
}
//  [c]
#include<stdio.h>

int main(void){
  int x,n,i;
  scanf("%d%d",&n,&x);
  int l[n];
  int d[n];
  d[0]=0;
  for(i=0;i<n;i++){
    scanf("%d ",&l[i]);
  }
  
  for(i=1;i<=n;i++){
    d[i]=d[i-1]+l[i-1];
  
  }
  int cout;
  
  for(i=0;i<=n;i++){
    if(d[i]<=x){
      cout++;
    
    }
  
  }
  printf("%d",cout);
  return 0;

}
//  [c]
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int n, l[105], x, ans = 1;
  scanf("%d %d", &n, &x);
  for(int i = 0; i < n; i++) scanf("%d", &l[i]);

  int d = 0;
  for(int i = 1; i <= n; i++){
    d += l[i - 1];
    if(d <= x) ans++;
  }

  printf("%d\n", ans);

  return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>

int main(void) {
  int n, x, i;
  int *l;
  scanf("%d %d", &n, &x);
  l = (int*)malloc(n * sizeof(int));
  for(i=0; i<n; i++) {
    scanf("%d", &l[i]);
  }
  int d=0;
  for(i=0; d<=x && i<n; i++) {
    d += l[i];
  }
  if(d<=x) {
    i++;
  }
  printf("%d\n", i);
  return 0;
}
//  [c]
#include<stdio.h>

int main(void) {
   int N, X;

   scanf("%d %d",&N, &X);

   int L[N];

   for(int i = 0; i < N; i++) {
      scanf("%d", &L[i]);
   }

   int D[N];
   D[0] = 0;

   for(int i = 1; i < N; i++) {
      D[i] = D[i-1] + L[i-1];
   }

   int cnt = 0;

   for(int i = 0; i < N; i++) {
      if(D[i] <= X) {
         cnt++;
      }
   }

   printf("%d\n", cnt);


   return 0;
}
//  [c]
n, x = map(int, input().split())
l = list(map(int, input().split()))

cnt = 1
a = 0
for i in range(0, len(l)):
  a += l[i]
  if(a <= x):
    cnt = cnt + 1

print(cnt)
//  [c]
 #include<stdio.h>
 int main(void)
 {
     int N,X,i,V;
     int D[101],L[101];
 
     scanf("%d%d",&N,&X);
 
     for(i=1;i<=N;i++)
       scanf("%d",&L[i-1]);
 
     for(i=1;i<=N;i++){
         D[0]=0;
         D[i]=D[i-1]+L[i-1];
     }
 
     for(i=0;i<=N;i++)
         if(D[i]<=X) V++;
 
     printf("%d\n",V);
 
     return 0;
 }
//  [javascript]
function main(input) {
    a = input[0].split(' ');
    n = a[0];
    x = a[1];
    l = input[1].split(' ');
    var i,value = 0, ans = 0;
    for(i=0; i<n; i++) {
        l[i] = parseInt(l[i], 10);
        if (value <= x) {
            ans++;
            value += l[i];
        }
    }
    if (value <= x) ans++;
    console.log(ans);
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));
//  [javascript]
'use strict'
function Main(input) {
  let jumpNum = input.split("\n")[0].split(" ")[0]*1;
  let jumpLimit = input.split("\n")[0].split(" ")[1]*1;
  let arr = input.split("\n")[1].split(" ");
  let count = 1;
  let sum = 0;
  for(let i in arr){
    sum += arr[i]*1;
    if(sum <= jumpLimit){
    	count++;
    }
    else{
		break;
    }
  }
  console.log(count);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
    input = input.trim().split("\n");
    tmp = input[0].split(" ");
    var N = parseInt(tmp[0], 10);
    var X = parseInt(tmp[1], 10);
    var L = [];
    tmp = input[1].split(" ");
    for (var i = 0; i < N; i++){
        L[i] = parseInt(tmp[i], 10);
    }

    var D = 0;
    var bound = 1;
    for (var i = 0; i < N; i++){
        D += L[i];
        if (D > X) {
            break;
        }
        bound++;
    }
    console.log(bound);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function main(input) {
  const args = input.split('\n');
  const [N, X] = args[0].split(' ');
  const L = args[1].split(' ');
  const n = Number(N);
  let count = 0;
  const array = [0];
  for (let i = 0; i < n; i++) {
    array.push(count += Number(L[i]));
   }
  for (let i = 0; i < array.length; i++) {
    if (array[i] > X) {
      console.log(i)
      return
    }
  }
  return; 
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function main(input) {
  const args = input.split('\n');
  const [N, X] = args[0].split(' ');
  const L = args[1].split(' ');
  const n = Number(N);
  let count = 0;
  const array = [0];
  for (let i = 0; i < n; i++) {
    array.push(count += Number(L[i]));
   }
  for (let i = 0; i < array.length; i++) {
    if (array[i] > X) {
      console.log(i)
      return
    }
  }
  return; 
}
//  [javascript]
function main(input) {
  const args = input.split('\n');
  const [N, X] = args[0].split(' ');
  const L = args[1].split(' ');
  const n = Number(N);
  let count = 0;
  for (let i = 0; i < n + 1; i++) {
    if (X < count) {
      console.log(i)
      return;
    }
    count += Number(L[i]);
   }
  return; 
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [go]
package main

import "fmt"

func main() {
	var N, X int
	fmt.Scanf("%d %d", &N, &X)
	L := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &L[i])
	}
	D := 0
	count := 0
	for i := 0; i < N; i++ {
		if D <= X {
			count++
		}
		D += L[i]
	}
	if D <= X {
		count++
	}
	fmt.Println(count)
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

func main() {
	list := getStdinIntArr()
	N := list[0]
	X := list[1]
	L := getStdinIntArr()
	D := make([]int, 0)
	D = append(D, 0)

	cnt := 1
	for i := 0; i < N; i++ {
		D1 := D[i] + L[i]
		D = append(D, D1)
		if D1 > X {
			break
		}
		cnt++
	}

	fmt.Printf("%d\n", cnt)
}

func getStdin() string {
	return readLine()
}
func getStdinArr() []string {
	str := getStdin()
	list := strings.Split(str, " ")
	return list
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var n, x int
	fmt.Scan(&n, &x)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	l := make([]int, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		l[i], _ = strconv.Atoi(sc.Text())
	}

	d := 0
	ans := 1
	for i := 1; i < n; i++{
		d += l[i-1]

		if d <= x {
			ans++
		}
	}
	fmt.Println(ans)
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var n, x int
	fmt.Scan(&n, &x)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	l := make([]int, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		l[i], _ = strconv.Atoi(sc.Text())
	}

	d := 0
	ans := 1
	for i := 1; i < n; i++{
		d += l[i]

		if d <= x {
			ans++
		}
	}
	fmt.Println(ans)
}
//  [ruby]
n, x = gets.chomp.split(" ").map(&:to_i)
li = gets.chomp.split(" ").map(&:to_i)
ans = 1
dist = 0
li.each do |e|
    dist += e
    break if dist > x
    ans += 1
end
puts ans
//  [ruby]
# frozen_string_literal: true

n, x = gets.split.map(&:to_i)
l = gets.split.map(&:to_i)
pt = 0

l.each_with_index do |i, idx|
  pt += i
  if pt > x
    puts idx + 1
    exit
  end
end

puts n + 1
//  [ruby]
n, x = gets.split(/ /).map(&:to_i)
l_list = gets.split(/ /).map(&:to_i)

# puts "n: #{n}"
# puts "x: #{x}"
# puts "l_list: #{l_list.inspect} (#{l_list.length})"

class Jump
  def initialize(d, index)
    @d = d
    @index = index
  end

  attr_reader :d, :index
end

d = [Jump.new(0, 1)]
l_list.each.with_index(1) do |l, i|
  d_next = d.last.d + l
  if d_next <= x
    d.push(Jump.new(d_next, i + 1))
  else
    break
  end
end

puts d.last.index
//  [ruby]
input = readlines()

n, x = input.shift.chomp.split("\s").map{|x| x.to_i}
list = input.shift.chomp.split("\s").map{|x| x.to_i}

cnt = 1
list.each do |l|
  cnt += 1 if l <= x
end

puts cnt
//  [ruby]
input = readlines()

n, x = input.shift.chomp.split("\s").map{|x| x.to_i}
list = input.shift.chomp.split("\s").map{|x| x.to_i}

cnt = 0
list.each do |l|
  cnt += 1 if l <= x
end

puts cnt
//  [ruby]
n,x=gets.split.map(&:to_i)
l=gets.split.map(&:to_i)
sum=[0]
ans=0
(0...n).each do |m|
  ans+=1
  sum[m+1]=sum[m]+l[m]
  break if sum[m+1]>x
end
p ans
//  [rust]
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let x: i64 = sc.cin();
    let mut u = 0;
    let mut ans = 1;
    for _ in 0..n {
        let ell: i64 = sc.cin();
        u += ell;
        if u <= x {
            ans += 1;
        }
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: u32,
        x: u32,
        ll: [u32;n]
    }
    let mut a = 0;
    let mut cnt = 0;
    for l in ll {
        a += l;
        if a <= x {
            cnt += 1;
        }
    }
    println!("{}", cnt+1);
}
//  [rust]
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: usize, x: usize, l: [usize; n]);

    let mut count = 0;
    let mut d = 0;
    loop {
        if x < d || count >= n {
            break;
        }

        d += l[count];

        count += 1;
    }

    println!("{}", count);
}
//  [rust]
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: usize, x: usize, l: [usize; n]);

    let mut count = 0;
    let mut d = 0;
    loop {
        if x < d || count >= n + 1 {
            break;
        }

        d += l[count];

        count += 1;
    }

    println!("{}", count);
}
//  [swift]
let inp = readLine()!.split(separator: " ").map { Int($0)! }

let N = inp[0]
let X = inp[1]

let L = readLine()!.split(separator: " ").map { Int($0)! }

var current = 0

var d = 0
var i = 0
while i < L.count {
  if d + L[i] > X {
    break
  }
  d += L[i]
  i += 1
}
print(i + 1)
//  [swift]
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let (N, X) = (input[0], input[1])
let L = readLine()!.characters.split(" ").map{Int(String($0))!}
var sum = [0]
(0..<N).forEach{sum+=[sum[$0]+L[$0]]}
print(sum.reduce(0){$0+($1>X ?0:1)})
//  [swift]
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let (N, X) = (input[0], input[1])
let L = readLine()!.characters.split(" ").map{Int(String($0))!}
var D = 0
print(L.reduce(1){D+=$1;return $0+(D>X ?0:1)})
//  [swift]
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let (N, X) = (input[0], input[1])
let L = readLine()!.characters.split(" ").map{Int(String($0))!}
var sum = [0]
(0..<N).forEach{sum+=[sum[$0]+A[$0]]}
print(sum.reduce(0){$0+($1>X ?0:1)})
//  [swift]
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let (N, X) = (input[0], input[1])
let L = [0] + readLine()!.characters.split(" ").map{Int(String($0))!}
(0..<N).reduce(1){$0+(L[$1]+L[$1+1]>X ?0:1)}
//  [swift]
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let (N, X) = (input[0], input[1])
let L = [0] + readLine()!.characters.split(" ").map{Int(String($0))!}
(1..<N).reduce(1){$0+(L[$1-1]+L[$1]>X ?0:1)}
//  [typescript]
export class Main {
  static main(input): string {
    const tmp: string[] = input.split("\n");
    const [n, x]: number[] = tmp[0].split(" ").map(Number);
    const l: number[] = tmp[1].split(" ").map(Number);
    let d: number = 0;
    let result: number = 1;
    for (let i: number = 0; i < n; ++i) {
      d += l[i];
      if (d <= x) {
        ++result;
      } else {
        break;
      }
    }
    return `${result}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));
//  [typescript]
import * as fs from 'fs';

namespace AtCoder.abc130 {
    class ProgramB {
        args: string[];

        // 3 6
        // 3 4 5
        //
        // 2
        constructor(args: string[]) {
            this.args = args;
        }

        main(this: ProgramB) {

            const [n, x]: number[] = this.args[0].split(' ').map(Number);
            const l: number[] = this.args[1].split(' ').map(Number);

            let d: number = 0;
            let ans: number = 0;
            l.forEach((val: number) => {
                if (d <= x) ans++;
                d += val;
            });

            if (d <= x) ans++;


            console.log(ans);

        }
    }

    const args: string[] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');
    new ProgramB(args).main();
}
//  [typescript]
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const [n, x] = input[0].split(" ").map((x: string): number => +x);
const l = input[1].split(" ").map((x: string): number => +x);

let result = 1;
let sum = 0;
for (let i = 0; i < n; i++) {
  sum += l[i];
  if (sum > x) break;
  result++;
}
console.log(result);