"use strict";

function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    let tmp = input[0].split(" ");
    let n = parseInt(tmp[0], 10);
    let m = parseInt(tmp[1], 10);
    let k = parseInt(tmp[2], 10);
    let a = input[1].split(" ").map(str => parseInt(str, 10));
    let b = input[2].split(" ").map(str => parseInt(str, 10));

    let aTime = [];
    let bTime = [];
    let books = 0;

    let x = 0;
    let time = 0;
    while (time < k) {
        aTime.push(time);
        time += a[x];
        x++;
    }

    x = 0;
    time = 0;
    while (time < k) {
        bTime.push(time);
        time += b[x];
        x++;
    }

    for (let i = 0; i < aTime.length; i++) {
        for (let j = 0; j < bTime.length; j++) {
            if ((aTime[i] + bTime[j]) <= k && (i + j) > books) {
                books = i + j;
            }
        }
    }

    //出力
    console.log(books);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));