using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace ABC
{
    class ABC172C
    {
        const string FILE = "/tmp/data.txt";

        static long N;
        static long M;
        static long K;
        static long[] A;
        static long[] B;

        static long nReadMax = 0;

        static void Main(string[] args)
        {
#if DEBUG
            Console.SetIn(new StreamReader(FILE));
#endif
            long[] La = RLa(3);
            N = La[0];
            M = La[1];
            K = La[2];
            A = RLa(N);
            B = RLa(M);

            long[] sumA = new long[N + 1];
            long[] sumB = new long[M + 1];

            int lastA = (int)(N);
            sumA[0] = 0;
            for (int i = 1; i <= N; ++i)
            {
                sumA[i] = sumA[i - 1] + A[i - 1];
                if (sumA[i] > K)
                {
                    lastA = i - 1;
                    break;
                }
            }

            int lastB = (int)(M);
            sumB[0] = 0;
            for (int i = 1; i <= M; ++i)
            {
                sumB[i] = sumB[i - 1] + B[i - 1];
                if (sumB[i] > K)
                {
                    lastB = i - 1;
                    break;
                }
            }

            /*
            long readN = lastA;
            long sumK = sumA[lastA];
            for (int j = 0; j < lastB; ++j)
            {
                if (sumK + sumB[j] > K)
                {
                    readN = lastA + j;
                    break;
                }
            }
            */

            int readN = lastA;
            for (int ai = lastA; ai >= 0; --ai)
            {
                long sumK = sumA[ai];
                int bi;
                for (bi = readN - ai; bi <= lastB; ++bi)
                {
                    if (sumK + sumB[bi] > K)
                    {
                        break;
                    }
                    readN += 1;
                }
                if (bi > lastB)
                {
                    readN = ai + lastB;
                    break;
                }
            }
            Console.WriteLine(readN);




#if DEBUG
            Console.WriteLine("*** end ***");
            Console.SetIn(Console.In);
            Console.ReadKey();
#endif
        }

        static void read(long sumK, int nRead, int ai, int bi)
        {
            if (ai < N && sumK + A[ai] <= K)
            {
                read(sumK + A[ai], nRead + 1, ai + 1, bi);
            }
            if (bi < M && sumK + B[bi] <= K)
            {
                read(sumK + B[bi], nRead + 1, ai, bi + 1);
            }

            if (nRead > nReadMax)
            {
                nReadMax = nRead;
            }
        }

        static long RL()
        {
            return long.Parse(Console.ReadLine());
        }

        static long[] RLa2(long n)
        {
            string[] sa = Console.ReadLine().Split(' ');
            long[] la = new long[n + 1];
            la[0] = 0;
            for (int i = 1; i < n; ++i)
            {
                la[i] = long.Parse(sa[i]);
            }
            return la;
        }

        static long[] RLa(long n)
        {
            string[] sa = Console.ReadLine().Split(' ');
            long[] la = new long[n];
            for (int i = 0; i < n; ++i)
            {
                la[i] = long.Parse(sa[i]);
            }
            return la;
        }
    }
}


Measured memory_bytes: 69224