n = int(input())
string = input()
flag=0
initial_data = string[0]
for data in string:
    if data<initial_data:
        flag=1
    initial_data = data
if not flag:
    print('NO')
else:
    min_position = -1
    max_position = -1
    min_character = string[0]
    for i in range(0,len(string)):
        if string[i]<=min_character:
            min_character = string[i]
            min_position = i
    for j in range(i):
        if string[j]>min_character:
            max_position = j
            break
    first_part = string[0:max_position]
    middle_part = string[max_position:min_position+1]
    last_part = string[min_position:n-1]
    final = first_part+middle_part[::-1]+last_part
    print(max_position+1,min_position+1)