Imports System
Imports System.Linq

Class Program
    Shared Sub Main(args As String())
        Dim input As String() = Console.ReadLine().Split(" ")
        Dim n As Long = CLng(input(0))
        Dim m As Long = CLng(input(1))
        Dim k As Long = CLng(input(2))
        Dim ai = Console.ReadLine().Split(" ").Select(Of Long)(Function(x) CLng(x)).ToList()
        Dim bi = Console.ReadLine().Split(" ").Select(Of Long)(Function(x) CLng(x)).ToList()
        Dim cntA As Long = 0
        Dim cntB As Long = 0

        Do While True
            If n = cntA Then
                If m = cntB Then
                    Exit Do
                ElseIf bi(cntB) <= k Then
                    k -= bi(cntB)
                    cntB += 1
                Else
                    Exit Do
                End If

            ElseIf m = cntB Then
                If ai(cntA) <= k Then
                    k -= ai(cntA)
                    cntA += 1
                Else
                    Exit Do
                End If

            Else
                If {ai(cntA), bi(cntB)}.Min <= k Then
                    k -= {ai(cntA), bi(cntB)}.Min
                    If ai(cntA) = {ai(cntA), bi(cntB)}.Min Then
                        cntA += 1
                    Else
                        cntB += 1
                    End If
                Else
                    Exit Do
                End If

            End If
        Loop

        Console.WriteLine(cntA + cntB)
    End Sub
End Class