'use strict'
const input = require('fs').readFileSync('/dev/stdin', 'utf8').split("\n");
const situation = input[0].split(" ").map(str => parseInt(str,10));
const nt = input[1].split(" ").map(str => parseInt(str,10));
const mt = input[2].split(" ").map(str => parseInt(str,10));
const k = situation[2];
let time = 0;
let count = 0;
if (nt[0] > k && mt[0] > k) { return console.log(0) }
while (time+nt[0] <= k || time+mt[0]<=k ) {
    if (nt[0] < mt[0]) {
        time += nt.shift();
        count++;
    } else if (nt[0] > mt[0]) {
        time += mt.shift();
        count++;
    } else if (nt.length === 0) {
        time += mt.shift();
        count++;
    } else if (mt.length === 0) {
        time += nt.shift();
        count++;
    } else { 
        break;
    }
}
console.log(count);

