output_description: Print the value a + a^2 + a^3 as an integer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      a
attempt: # -*- coding: utf-8 -*-
  
  
  # def main():
  #     n, m, k = map(int, input().split())
  #     A = list(map(int, input().split()))
  #     B = list(map(int, input().split()))
  #     a = A[0]
  #     A2 = [a]
  #     b = B[0]
  #     B2 = [b]
  #     for i in range(1, n):
  #         a += A[i]
  #         A2.append(a)
  #
  #     for i in range(1, m):
  #         b += B[i]
  #         B2.append(b)
  #     max = -2
  #     for ia, aa in enumerate(A2):
  #         for ib, bb in enumerate(B2):
  #             if aa + bb > k:
  #                 break
  #             if ia + ib > max:
  #
  #                 max = ia + ib
  #     print(max + 2)
  #
  
  
  def answer():
      N, M, K = map(int, input().split())
  
      A = list(map(int, input().split()))
      B = list(map(int, input().split()))
  
      a, b = [0], [0]
      for i in range(N):
          a.append(a[i] + A[i])
      for i in range(M):
          b.append(b[i] + B[i])
  
      ans, j = 0, M
      for i in range(N + 1):
          if a[i] > K:
              break
          while b[j] > K - a[i]:
              j -= 1
          ans = max(ans, i + j)
      print(ans)
  
  
  if __name__ == "__main__":
      answer()
  
problem_description: Statement
  
  Given an integer a as input, print the value a + a^2 + a^3.
samples: [{"input": "2", "output": "14\n    \n\nWhen a = 2, we have a + a^2 + a^3 = 2 + 2^2 + 2^3 = 2 + 4 + 8 = 14.\n\nPrint the answer as an input. Outputs such as `14.0` will be judged as\nincorrect.\n\n* * *"}, {"input": "10", "output": "1110"}]