var GET = (function () {function f(s) {return new g(s);}function g(s) {this._s = s.trim().split("\n");}g.prototype.getValue = function (n) {return this._s[n];};g.prototype.getArray = function (n) {return this.stoa(this._s[n]);};g.prototype.slice = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stox(v));};g.prototype.sliceArray = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stoa(v));};g.prototype.stoa = function (s) {return s.split(" ").map(v => this.stox(v));};g.prototype.stox = function (v) {var i = +v;return (i === i) ? i : v;};return f;})();
var o = GET(require("fs").readFileSync("/dev/stdin", "utf8"));

console.log(main());
function main(){
    var row = o.getArray(0);
    var N = +row[0];
    var M = +row[1];
    var K = +row[2];

    var ai = o.getArray(1);
    var bi = o.getArray(2);

    var minutes = 0;
    var count = 0;
    while(!(ai.length === 0 && bi.length === 0)) {
        if (ai[0] < bi[0]) {
            minutes += ai.shift();
        } else {
            minutes += bi.shift();
        }

        if (minutes > K) {
            break;
        }

        count++;
    }

    return count;
}