cswork / OAOpen practice workspace

JPMorgan ChaseOA #27

First Unique Character (Data & Analytics)

Estimated EasyJudge-ready

Topics (AI-labelled)Hashing

Return the index of the first character in a lowercase string that appears exactly once in the whole string, using 1-based indexing; return −1 if there is none.

Input

The first line contains n, and the second line contains the string; 1≤n≤100000, lowercase English letters only.

Output

Output a single integer answer.

Example 1

Input:

10
statistics

Output:

3

Example 2

Input:

11
hackthegame

Output:

3

Example 3

Input:

4
aabb

Output:

-1

Example notes

The outputs of the three public examples are, in order: 3; 3; -1. These answers have been checked by independent enumeration or direct simulation.

Editorial

Loading solution…