//
//  main.swift
//
//  Created by sun-yryr
//  Copyright © 2019 sun-yryr. All rights reserved.
//

import Foundation

prefix operator *
prefix func * <T> (a: [T]) -> (T, T) {return (a[0], a[1])}
prefix func * <T> (a: [T]) -> (T, T, T) {return (a[0], a[1], a[2])}


func readInt(separator s: Character = " ") -> [Int] {return readLine()!.split(separator: s).map({Int($0)!})}
func readDouble(separator s: Character = " ") -> [Double] {return readLine()!.split(separator: s).map({Double($0)!})}
func readElement(separator s: Character = " ") -> [String] {return readLine()!.split(separator: s).map({String($0)})}

extension String {
    func at(_ i: Int) -> Character {
        precondition(0 <= i && i < self.count)
        return self[self.index(self.startIndex, offsetBy: i)]
    }
}

func main() {
    let (N, M, K) = *readInt()
    var A = readInt()
    var B = readInt()
    var ai = 0, bi = 0
    var timer = 0, counter = 0
    while (timer <= K) {
        let aEmpty = ai == A.count
        let bEmpty = bi == B.count
        if (aEmpty && bEmpty) {
            counter += 1
            break
        } else if (aEmpty) {
            timer += B[bi]
            bi += 1
        } else if (bEmpty) {
            timer += A[ai]
            ai += 1
        } else {
            let aTimer = timer + A[ai]
            let bTimer = timer + B[bi]
            if (aTimer > bTimer) {
                timer = bTimer
                bi += 1
            } else if (aTimer < bTimer) {
                timer = aTimer
                ai += 1
            } else {
                if (aTimer > K) {
                    counter += 1
                    break
                }
                A[ai+1] += A[ai]
                B[bi+1] += B[bi]
                ai += 1
                bi += 1
            }
        }
        counter += 1
    }
    print(counter - 1)
}
main()
