#C94. Find the Index of the Target Word

    ID: 53488 Type: Default 1000ms 256MiB

Find the Index of the Target Word

Find the Index of the Target Word

You are given a string text containing words separated by spaces and a target word target. Your task is to determine the 0-based index of the first occurrence of target in the list of words. If the target word is not present, output -1.

The implementation must read from standard input (stdin) and write the result to standard output (stdout). For instance, given a text string and a target word, if the word exists, print its index; otherwise, print -1.

The search is case-sensitive.

inputFormat

The input consists of two lines:

  1. The first line contains the string text (a list of words separated by spaces).
  2. The second line contains the target word target.

outputFormat

Output a single integer representing the 0-based index of the first occurrence of the target word in the text. If the target word is not found, output -1.

## sample
Hello world this is a sample text
sample
5