#[allow(unused_imports)]
use std::cmp::{max,min};
#[allow(unused_imports)]
use std::collections::{HashMap,HashSet,VecDeque};

#[allow(unused_macros)]
macro_rules! readln {
  () => {{
    use std::io;

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_string()
  }};
  ( $t:ty ) => {{
    let input = readln!();
    input.parse::<$t>().unwrap()
  }};
  ( $( $t:ty ),+ ) => {{
    let input = readln!();
    let mut input = input.split_whitespace();
    (
     $(
       input.next().unwrap().parse::<$t>().unwrap(),
      )+
    )
  }}
}

#[allow(unused_macros)]
macro_rules! readvec {
  ( $t:ty ) => {{
    let input = readln!();
    let mut input = input.split_whitespace();
    let mut result = Vec::new();
    for elem in input {
      result.push(elem.parse::<$t>().unwrap());
    }
    result
  }}
}

fn main() {
  let (n,k) = readln!(i32,i32);
  let a = readvec!(i32);
  let mut res = vec![n as usize;k as usize];
  for i in 0..k {
    for j in 0..n {
      let mut good = true;
      for kk in 0..i {
        if a[res[kk as usize]] == a[j as usize] {
          good = false;
          break;
        }
      }
      if good {
        res[i as usize] = j as usize;
        break;
      }
    }
    if res[i as usize] == n as usize{
      println!("NO");
      return;
    }
  }
  println!("YES");
  println!("{}",res.iter().map(|&x|(x+1).to_string()).collect::<Vec<String>>().join(" "));
}

use std::io;

fn read_vector() -> Vec<i32> {
	let mut input = String::new();
	io::stdin().read_line(&mut input).expect("Reading error");

	return input.split_whitespace().map(|s| s.trim().parse::<i32>().unwrap()).collect();
}

fn new_rank(ranks: &Vec<i32>, indexes: &Vec<i32>, rank: i32) -> bool {
	for ind in indexes {
		if ranks[*ind as usize] == rank {
			return false;
		}
	}
	return true;
}

fn main() {
	let nums = read_vector();
	let team_size = nums[1];

	let ranks = read_vector();
	let mut team = Vec::<i32>::new();

	for tup in ranks.iter().enumerate() {
		if new_rank(&ranks, &team, *tup.1) {
			team.push(tup.0 as i32);
		}
		if team.len() >= (team_size as usize) {
			break;
		}
	}

	if team.len() >= (team_size as usize) {
		println!("YES");
		for rank in team {
			print!("{} ", rank + 1);
		}
	} else {
		println!("NO");
	}
}

//spnauti-rust
use std::io::*;
use std::str::*;
use std::fmt::Debug;
#[allow(unused_imports)] use std::cmp::Ordering::*;
#[allow(unused_imports)] use std::collections::*;

#[allow(unused_macros)]
macro_rules! a {
    ($c: tt, $x: expr, $y: expr) => {{
        let b = $y; let a = &mut $x;
        if b $c *a { *a = b; true } else { false }
    }};
}
struct WordReader<'a> { it : SplitAsciiWhitespace<'a>, }
#[allow(dead_code)]
impl<'a> WordReader<'a> {
    fn new<T: Read>(b: &mut String, mut r: T) -> WordReader {
        b.clear();
        r.read_to_string(b).unwrap();
        WordReader { it: b.split_ascii_whitespace() }
    }
    fn from_stdin(b: &mut String) -> WordReader {
        WordReader::new(b, stdin())
    }
    fn sl(&mut self) ->  &str { self.it.next().unwrap() }
    fn bs(&mut self) -> &[u8] { self.sl().as_bytes()    }
    fn s(&mut self) -> String { String::from(self.sl()) }
    fn i(&mut self) ->    i32 { self.p()                }
    fn u(&mut self) ->  usize { self.p()                }
    fn vi(&mut self, n: usize) -> Vec<i32> {
        self.vp::<i32>(n)
    }
    fn p<T: FromStr>(&mut self) -> T where T::Err: Debug {
        self.sl().parse::<T>().unwrap()
    }
    fn vp<T: FromStr>(&mut self, n: usize) -> Vec<T> where T::Err: Debug {
        (0..n).map(|_| self.p()).collect()
    }
}

#[allow(dead_code)]
fn build_counting_hashmap<K: Eq + std::hash::Hash, T>(i: T) -> HashMap<K,usize>
    where T: Iterator<Item = K> {
    let mut m = HashMap::new();
    for k in i {
        let n = 1 + if let Some(&n) = m.get(&k) { n } else { 0 };
        m.insert(k, n);
    }
    m
}

fn main() {
    let mut bin = String::new();
    let mut input = WordReader::from_stdin(&mut bin);

    let n = input.u();
    let k = input.u();
    let res = input.vi(n).into_iter().enumerate().map(|(a,b)| (b,a)).collect::<HashMap<_,_>>();
    if res.len() < k {
        println!("NO");
    } else {
        println!("YES");
        for x in res.values().take(k) {
            print!("{} ", x + 1);
        }
    }
}

use std::io;
use std::collections::HashMap;

fn main() {
    let mut l1 = String::new();
    let mut l2 = String::new();
    {
        let stdin = io::stdin();
        stdin.read_line(&mut l1).unwrap();
        stdin.read_line(&mut l2).unwrap();
    }

    let p: Vec<usize> = l1.trim()
        .split(" ")
        .map(|val| val.parse().unwrap())
        .collect();

    let mut k = p[1];

    let h: HashMap<usize, usize> = l2.trim()
        .split(" ")
        .map(|val| val.parse().unwrap())
        .enumerate()
        .map(|(a, b)| (b, a))
        .collect();

    // println!("{:?}", h);
    // println!("k: {}", k);
    // println!("h.len(): {}", h.len());

    if h.len() >= k {
        println!("YES");
        let mut hm_iter = h.iter();
        while k > 1 {
            k -= 1;

            print!("{} ", hm_iter.next().unwrap().1 + 1);
        }
        println!("{}", hm_iter.next().unwrap().1 + 1);
    } else {
        println!("NO");
    }
}

#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_labels)]

use std::char::*;
use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::str::FromStr;

macro_rules! debug {($($a:expr),*) => {eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::f64;

fn min<T: PartialOrd>(a:T, b:T) -> T {
    if a < b { a }
    else { b }
}

fn max<T: PartialOrd>(a:T, b:T) -> T {
    if a < b { b }
    else { a }
}

const MAX:usize = 30;
const INF:i64 = std::i64::MAX;
const MOD:i64 = 1e9 as i64 + 7;

struct Graph {
    e: Vec<Vec<usize>>,
    v: Vec<usize>,
    u: Vec<usize>,
    f: Vec<bool>,
    c: i64,
    vc: Vec<i64>,
}

impl Graph {
    fn new(n:usize) -> Self {
        Graph {
            e: vec![vec![];n],
            v: vec![],
            u: vec![n;n],
            f: vec![false;n],
            c: 0,
            vc: vec![0;n],
        }
    }

    fn dfs(&mut self, crt: usize) {
        if self.f[crt] { return; }
        self.c += 1;
        self.f[crt] = true;
        self.v.push(crt);
        self.vc[crt] = self.c;
        self.u[crt] = self.v.len()-1;
        for i in 0..self.e[crt].len() {
            self.dfs(self.e[crt][i]);
        }
        //debug!(crt, self.c, self.vc[crt]);
        self.vc[crt] = self.c - self.vc[crt];
    }
}

fn main() {
    //let t:usize = read();

    //'outer: for _ in 0..t {
        let n:usize = read();
        let k:usize = read();
        let a:Vec<i64> = (0..n).map(|_| read()).collect();

        let mut f = vec![false;101];
        let mut cnt = 0;
        let mut v = vec![];
        for i in 0..n {
            if !f[a[i] as usize] {
                cnt += 1;
                v.push(i);
                f[a[i] as usize] = true;
            }
            if cnt == k { break; }
        }

        if cnt != k { println!("NO"); return; }
        println!("YES");
        for e in v {print!("{} ", e+1); } println!();

    //}
}

/*

*/

use std::collections::HashMap;

pub fn main() {
    let mut input = io::Input::new();

    let mut map = HashMap::new();

    let n = input.next::<i32>();
    let k = input.next::<usize>();

    for i in 1..(n+1) {
        let a = input.next::<i32>();
        map.entry(a).or_insert(i);
        if map.len() == k {
            break;
        }
    }

    if map.len() == k {
        println!("YES");

        let mut v = Vec::new();

        for (_, u) in map {
            v.push(u);
        }

        v.sort();

        for u in v {
            print!("{} ", u);
        }
        println!();
    } else {
        println!("NO");
    }
}

#[allow(unused)]
pub mod io {

    const BUFFER_SIZE: usize = 8192;

    use std::collections::VecDeque;
    use std::str::FromStr;
    use std::io;
    use std::io::Read;

    type AsciiStr = Vec<u8>;

    pub struct Input {
        token_buffer: VecDeque<String>,
        remaining: String,
    }

    impl Input {

        pub fn new() -> Input {
            Input {
                token_buffer: VecDeque::with_capacity(100),
                remaining: String::new(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T
            where T::Err: ::std::fmt::Debug
        {
            self.fill_buffer();
            self.token_buffer.pop_front().unwrap().parse().unwrap()
        }

        pub fn next_ascii_string(&mut self) -> AsciiStr {
            self.fill_buffer();
            Vec::from(self.token_buffer.pop_front().unwrap().as_bytes())
        }

        fn fill_buffer(&mut self) {
            while self.token_buffer.is_empty() {
                let mut minibuffer = [0u8; BUFFER_SIZE];
                let size = io::stdin().read(&mut minibuffer[..]).unwrap();

                self.remaining += &String::from_utf8_lossy(&minibuffer[..size]);

                if self.remaining.trim().len() > 0 {
                    for token in self.remaining.trim().split_whitespace() {
                        self.token_buffer.push_back(String::from(token))
                    }

                    if size > 0 && ! self.remaining.ends_with(|c: char|char::is_ascii_whitespace(&c)) {
                        self.remaining = self.token_buffer.pop_back().unwrap();
                    } else {
                        self.remaining.clear();
                    }

                } else if size == 0 {
                    panic!("EOF");
                }
            }
        }
    }
}

use std::collections::HashMap;
use std::io;

fn main()
{
    let mut line1 = String::new();
    let mut line2 = String::new();
    let mut team = HashMap::new();

    io::stdin().read_line(&mut line1).unwrap();
    io::stdin().read_line(&mut line2).unwrap();
    let nums: Vec<&str> = line1.trim().split_whitespace().collect();
    let rates: Vec<&str> = line2.trim().split_whitespace().collect();

    for i in 0..nums[0].parse().unwrap()
    {
        team.insert(rates[i], i + 1);
    }
    if team.len() < nums[1].parse().unwrap()
    {
        println!("{}", "NO");
        return;
    }
    else
    {
        println!("{}", "YES");
    }

    let mut it = team.iter();
    for _i in 0..nums[1].parse().unwrap()
    {
        if let Some((_, &output)) = it.next()
        {
            print!("{} ", output);
        }
    }

    print!("\n");
}

struct Scan {
    buffer: std::collections::VecDeque<String>,
}

impl Scan {
    fn new() -> Scan {
        Scan {
            buffer: std::collections::VecDeque::new(),
        }
    }

    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop_front() {
                break token.parse::<T>().ok().unwrap();
            }
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).expect("Fail to read");
            self.buffer = line.split_whitespace().map(String::from).collect();
        }
    }
}

fn _main() {
    let mut scan = Scan::new();
    let n: usize = scan.next();
    let m: usize = scan.next();
    let mut arr: Vec<(usize, usize)> = vec![];
    let mut result: Vec<usize> = vec![];
    for i in 1..=n {
        let current: usize = scan.next();
        arr.push((current, i));
    }
    arr.sort();
    result.push(arr[0].1);
    for i in 1..n {
        if arr[i].0 != arr[i - 1].0 {
            result.push(arr[i].1);
            if result.len() == m {
                break;
            }
        }
    }
    if result.len() < m {
        println!("NO");
    } else {
        println!("YES");
        for &item in result.iter() {
            print!("{} ", item);
        }
        println!();
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(1 << 23)
        .spawn(_main)
        .unwrap()
        .join()
        .unwrap();
}

use std::collections::BTreeSet;
use std::collections::BTreeMap;
use std::io;
use std::io::Stdin;
use std::str::FromStr;

fn read_line(stdin : &Stdin, line : &mut String) {
    match stdin.read_line(line) {
        Ok(_) => return,
        Err(msg) => panic!("Could not read line! Message: {}.", msg),
    }
}

fn parse_t<T : FromStr>(s : &str) -> T {
    match s.trim().parse() {
        Ok(y) => y,
        Err(_) => panic!("Could not read from string!"),
    }
}

fn read_ts<T : FromStr>(stdin : &Stdin, ts : &mut Vec<T>) {
    let mut line = String::new();
    read_line(stdin, &mut line);
    let word_iter = line.split_whitespace();
    for word in word_iter {
        let x = parse_t(word);
        ts.push(x);
    }
}

fn print_can_form_team(k : usize, ratings : &Vec<u64>) {
    let mut rating_index_map = BTreeMap::new();
    let mut index = 1;
    let mut distinct_ratings = BTreeSet::new();
    for rating in ratings {
        distinct_ratings.insert(rating);
        if rating_index_map.contains_key(&rating) {
            // Do nothing ...
        } else {
            rating_index_map.insert(rating, index);
        }
        index = index + 1;
    }
    let num_distinct_ratings = distinct_ratings.len();
    if num_distinct_ratings >= k {
        println!("YES");
        let mut i = 0;
        let mut is_first = true;
        for rating in distinct_ratings {
            if i < k {
                if is_first {
                    is_first = false;
                } else {
                    print!(" ");
                }
                print!("{}", rating_index_map.get(rating).unwrap());
            } else {
                break;
            }
            i = i + 1;
        }
        println!();
    } else {
        println!("NO");
    }
}

fn main() {
    let stdin = io::stdin();
    let mut n_k = vec![];
    read_ts(&stdin, &mut n_k);
    let k = n_k[1];
    let mut ratings = vec![];
    read_ts(&stdin, &mut ratings);
    print_can_form_team(k, &ratings);
}

use std::collections::HashMap;
use std::io::{self, BufRead, Write, stdin};

fn main() {

    let mut line = String::new();
    stdin().read_line(&mut line).ok();
    let params: Vec<i32> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();

    let k = params[1];

    let mut oline = String::new();
    stdin().read_line(&mut oline).ok();
    let elems: Vec<i32> = oline.split_whitespace().map(|s| s.parse().unwrap()).collect();

    let mut numbers = HashMap::new();
    for (pos, el) in elems.iter().enumerate() {
        if ! numbers.contains_key(el) {
            numbers.insert(el, pos);
        }
    }

    if (numbers.len() as i32) < k {
        println!("NO");
    } else {
        println!("YES");
        let mut i = 1;
        for (_, val) in numbers.iter() {
            if i > k {
                break;
            }
            if i == 1 {
                print!("{}", val + 1);
            } else {
                print!(" {}", val + 1);
            }
            i += 1;
        }
        io::stdout().flush().unwrap();
    }
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn solve() {
    let n = get();
    let k = get();
    let mut hm = HashMap::new();
    for i in 0 .. n {
        let rat: i64 = get();
        hm.insert(rat, i + 1);
    }
    if hm.len() < k {
        println!("NO");
    } else {
        println!("YES");
        let mut it = hm.iter();
        for i in 0 .. k {
            if let Some((_, x)) = it.next() {
                print!("{}{}", x, if i == k - 1 { "\n" } else { " " });
            }
        }
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

struct Scan {
    buffer: std::collections::VecDeque<String>,
}

impl Scan {
    fn new() -> Scan {
        Scan {
            buffer: std::collections::VecDeque::new(),
        }
    }

    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop_front() {
                break token.parse::<T>().ok().unwrap();
            }
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).expect("Fail to read");
            self.buffer = line.split_whitespace().map(String::from).collect();
        }
    }
}

fn _main() {
    let mut scan = Scan::new();
    let n: usize = scan.next();
    let m: usize = scan.next();
    let mut arr: Vec<(usize, usize)> = vec![];
    let mut result: Vec<usize> = vec![];
    for i in 1..=n {
        let current: usize = scan.next();
        arr.push((current, i));
    }
    arr.sort();
    result.push(arr[0].1);
    for i in 1..n {
        if arr[i].0 != arr[i - 1].0 {
            result.push(arr[i].1);
            if result.len() == m {
                break;
            }
        }
    }
    if result.len() < m {
        println!("NO");
    } else {
        for &item in result.iter() {
            print!("{} ", item);
        }
        println!();
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(1 << 23)
        .spawn(_main)
        .unwrap()
        .join()
        .unwrap();
}

use std::collections::HashMap;
use std::io::{self, BufRead, Write, stdin};

fn main() {

    let mut line = String::new();
    stdin().read_line(&mut line).ok();
    let params: Vec<i32> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();

    let k = params[1];

    let mut oline = String::new();
    stdin().read_line(&mut oline).ok();
    let elems: Vec<i32> = oline.split_whitespace().map(|s| s.parse().unwrap()).collect();

    let mut numbers = HashMap::new();
    for (pos, el) in elems.iter().enumerate() {
        if ! numbers.contains_key(el) {
            numbers.insert(el, pos);
        }
    }

    if (numbers.len() as i32) < k {
        println!("NO");
    } else {
        println!("YES");
        let mut i = 1;
        for (_, val) in numbers.iter() {
            if i == 1 {
                print!("{}", val + 1);
            } else {
                print!(" {}", val + 1);
            }
            i += 1;
        }
        io::stdout().flush().unwrap();
    }
}


use std::io;

// type Matrix = Vec<Vec<char>>;

fn read_line() -> String {
    let mut input_line = String::new();
    io::stdin().read_line(&mut input_line).unwrap();
    return String::from(input_line.trim());
}

fn read_line_vec() -> Vec<u32> {
    return read_line().split(' ')
        .map(|s| s.parse().unwrap())
        .collect();
}

fn main() {
    let mut n: u32 = read_line().parse().unwrap();
    let week = read_line_vec();
    let s: u32 = week.iter().sum();

    n = ((n - 1) % s) + 1;

    for i in 0..week.len() {
        if n <= week[i] {
            println!("{}", i + 1);
            break;
        }
        n -= week[i];
    }

}

use std::io;

fn raw_input() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_string()
}

fn input_split() -> Vec<u16> {
    raw_input()
        .split_whitespace()
        .map(|elem| elem.parse().unwrap())
        .collect()
}

fn input() -> u16 {
    raw_input().parse().unwrap()
}

fn main() {
    let mut n = input();
    let days = input_split();

    let week_total: u16 = days.iter().sum();
    while n > week_total {
        n -= week_total;
    }

    let mut current_day = 0;
    loop {
        if days[current_day] >= n {
            break;
        } else {
            n -= days[current_day];
        }
        current_day += 1;
    }

    print!("{}", current_day + 1);
}

#[allow(unused_imports)]
use std::cmp::{min,max};
use std::collections::{*};
use std::io::{BufWriter, stdin, stdout, Write};
const BITS: usize = 19;

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>
}
impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main() {
    let mut scanner = Scanner::default();
    let mut n: u128 = scanner.next();
    let mut week: Vec<u128> = (1..=7).map(|_| scanner.next()).collect();
    let mut cur: u128 = 0;
    let mut i: usize = 0;
    while cur < n {
    	cur += week[i];
    	if cur >= n {
    		println!["{}", i+1];
    	}
    	i += 1;
    	i %= 7;
    }
}

fn main() {
    let n: u32 = get_input().parse().unwrap();
    let days: Vec<u32> = get_input().split_ascii_whitespace().map(|v| v.parse().unwrap()).collect();
    let total: u32 = days.iter().sum();
    //println!("total is {}", total);
    let m =  {
        if total > n {
            n
        } else if total == n || n % total == 0 {
            total
        } else {
            n % total
        }
    };

    let mut c = 0;

    //println!("mod is {}", m);
    for i in 0..days.len() {
        //println!("c is {}", c);
        c += days[i];

        if c >= m {
            println!("{}", i+1);
            break;
        }
    }
}

fn get_input() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("Failed");
    buffer.trim().to_owned()
}

fn get_input_usize() -> usize {
    get_input().parse().unwrap()
}

fn main() {
    let n: u32 = get_input().parse().unwrap();
    let days: Vec<u32> = get_input().split_ascii_whitespace().map(|v| v.parse().unwrap()).collect();
    let total: u32 = days.iter().sum();
    //println!("total is {}", total);
    let m =  {
        if total > n {
            n % total
        } else if total == n {
            n
        } else {
            n - total
        }
    };

    let mut c = 0;

    //println!("mod is {}", m);
    for i in 0..days.len() {
        //println!("c is {}", c);
        c += days[i];

        if c >= m {
            println!("{}", i+1);
            break;
        }
    }
}

fn get_input() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("Failed");
    buffer.trim().to_owned()
}

fn get_input_usize() -> usize {
    get_input().parse().unwrap()
}

fn main() {
    let n: u32 = get_input().parse().unwrap();
    let days: Vec<u32> = get_input().split_ascii_whitespace().map(|v| v.parse().unwrap()).collect();
    let total: u32 = days.iter().sum();
    //println!("total is {}", total);
    let m =  {
        if total > n {
            n
        } else if total == n {
            n
        } else {
            total
        }
    };

    let mut c = 0;

    //println!("mod is {}", m);
    for i in 0..days.len() {
        //println!("c is {}", c);
        c += days[i];

        if c >= m {
            println!("{}", i+1);
            break;
        }
    }
}

fn get_input() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("Failed");
    buffer.trim().to_owned()
}

fn get_input_usize() -> usize {
    get_input().parse().unwrap()
}

fn main() {
    let n: u32 = get_input().parse().unwrap();
    let days: Vec<u32> = get_input().split_ascii_whitespace().map(|v| v.parse().unwrap()).collect();
    let total: u32 = days.iter().sum();

    let m =  {
        if total == n {
            n
        } else {
            n % total
        }
    };

    let mut c = 0;
    for i in 0..days.len() {
        c += days[i];

        if c >= m {
            println!("{}", i+1);
            break;
        }
    }
}

fn get_input() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("Failed");
    buffer.trim().to_owned()
}

fn get_input_usize() -> usize {
    get_input().parse().unwrap()
}

fn main() {
    let n: u32 = get_input().parse().unwrap();
    let days: Vec<u32> = get_input().split_ascii_whitespace().map(|v| v.parse().unwrap()).collect();
    let total: u32 = days.iter().sum();

    let m =  {
        if total > n {
            n % total
        } else if total == n {
            n
        } else {
            total % n
        }
    };

    let mut c = 0;
    for i in 0..days.len() {
        c += days[i];

        if c >= m {
            println!("{}", i+1);
            break;
        }
    }
}

fn get_input() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("Failed");
    buffer.trim().to_owned()
}

fn get_input_usize() -> usize {
    get_input().parse().unwrap()
}

fn main() {
    let n: u32 = get_input().parse().unwrap();
    let days: Vec<u32> = get_input().split_ascii_whitespace().map(|v| v.parse().unwrap()).collect();
    let total: u32 = days.iter().sum();
    //println!("total is {}", total);
    let m =  {
        if total > n {
            total % n
        } else if total == n {
            n
        } else {
            n % total
        }
    };

    let mut c = 0;

    //println!("mod is {}", m);
    for i in 0..days.len() {
        //println!("c is {}", c);
        c += days[i];

        if c >= m {
            println!("{}", i+1);
            break;
        }
    }
}

fn get_input() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("Failed");
    buffer.trim().to_owned()
}

fn get_input_usize() -> usize {
    get_input().parse().unwrap()
}

fn main() {
    let n: u32 = get_input().parse().unwrap();
    let days: Vec<u32> = get_input().split_ascii_whitespace().map(|v| v.parse().unwrap()).collect();
    let total: u32 = days.iter().sum();

    let m =  {
        if total == n {
            n
        } else {
            n % total
        }
    };

    let mut c = 0;

    println!("mod is {}", m);
    for i in 0..days.len() {
        println!("c is {}", c);
        c += days[i];

        if c >= m {
            println!("{}", i+1);
            break;
        }
    }
}

fn get_input() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("Failed");
    buffer.trim().to_owned()
}

fn get_input_usize() -> usize {
    get_input().parse().unwrap()
}

fn main() {
    let n: u32 = get_input().parse().unwrap();
    let days: Vec<u32> = get_input().split_ascii_whitespace().map(|v| v.parse().unwrap()).collect();
    let total: u32 = days.iter().sum();

    let m =  n % total;

    let mut c = 0;
    for i in 0..days.len() {
        c += days[i];

        if c >= m {
            println!("{}", i+1);
            break;
        }
    }
}

fn get_input() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("Failed");
    buffer.trim().to_owned()
}

fn get_input_usize() -> usize {
    get_input().parse().unwrap()
}

fn main() {
    let n: u32 = get_input().parse().unwrap();
    let days: Vec<u32> = get_input().split_ascii_whitespace().map(|v| v.parse().unwrap()).collect();
    let total: u32 = days.iter().sum();
    //println!("total is {}", total);
    let m =  {
        if total > n {
            n
        } else if total == n {
            n
        } else {
            n % total
        }
    };

    let mut c = 0;

    //println!("mod is {}", m);
    for i in 0..days.len() {
        //println!("c is {}", c);
        c += days[i];

        if c >= m {
            println!("{}", i+1);
            break;
        }
    }
}

fn get_input() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("Failed");
    buffer.trim().to_owned()
}

fn get_input_usize() -> usize {
    get_input().parse().unwrap()
}


#![allow(unused_imports)]
use std::io::{BufReader, BufWriter, stdin, stdout, Write};
use std::cmp::{min, max};
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet, BinaryHeap};

const m:i64 = 1000000007;

fn main() {
	let mut inp = Iinput::default();
	let out = &mut BufWriter::new(stdout());
	let n:usize = inp.scan::<usize>();
	let k:i64 = inp.scan::<i64>();
	let mut nCr = vec![vec![0 as i64; n + 1]; n + 1];
	nCr[0][0] = 1;
	for i in 1..n+1 {
		for j in 0..i+1 {
			if j > 0 {
				nCr[i][j] += nCr[i - 1][j - 1];
			}
			if j < i {
				nCr[i][j] += nCr[i - 1][j];
			}
			nCr[i][j] %= m;
		}
	}
	let mut dp = vec![0; n + 1];
	dp[0] = 1;
	let mut pow2 = vec![1 as i64; n + 1];
	for i in 1..n+1 {
		pow2[i] = pow2[i - 1] * (k - 1) % m;
	}
	for _row in 0..n {
		let mut tp = vec![0; n + 1];
		let mut powa = 1 as i64;
		for i in 0..n+1 {
			for j in i..n+1 {
				let mut val = pow2[n - j] * powa % m;
				if i == j {
					val += m - pow2[n];
				}
				val = val * nCr[n - i][n - j] % m;
				tp[j] = (tp[j] + val * dp[i]) % m;
			}
			powa = powa * k % m;
		}
		dp = tp;
	}
	writeln!(out, "{}", dp[n]);
}

#[derive(Default)]
struct Iinput {
	buffer: Vec<String>
}

impl Iinput {
	fn scan<T: std::str::FromStr>(&mut self) -> T {
		loop {
			if let Some(token) = self.buffer.pop() {
				return token.parse().ok().expect("Parsing Error");
			}
			let mut s = String::new();
			stdin().read_line(&mut s).expect("Reading Error");
			self.buffer = s.split_whitespace().rev().map(String::from).collect();
		}
	}
}

mod io {
    use std::io::{self, BufRead};
    use std::str::{self, FromStr, SplitAsciiWhitespace};

    pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;

    pub struct Scanner<'a, R> {
        reader: R,
        buf_str: Vec<u8>,
        buf_iter: SplitAsciiWhitespace<'a>,
    }

    impl<R: BufRead> Scanner<'_, R> {
        pub fn new(reader: R) -> Self {
            Self {
                reader,
                buf_str: Vec::new(),
                buf_iter: "".split_ascii_whitespace(),
            }
        }

        pub fn try_token<T>(&mut self) -> Result<T>
            where T: FromStr,
                  <T as FromStr>::Err: 'static + std::error::Error
        {
            loop {
                if let Some(token) = self.buf_iter.next() {
                    return Ok(token.parse()?);
                }
                self.buf_str.clear();
                let bytes_read = self.reader
                    .read_until(b'\n', &mut self.buf_str)?;
                if bytes_read == 0 {
                    return Err(Box::new(io::Error::from(io::ErrorKind::UnexpectedEof)));
                }
                self.buf_iter = unsafe {
                    let slice = str::from_utf8_unchecked(&self.buf_str);
                    ::std::mem::transmute(slice.split_ascii_whitespace())
                }
            }
        }

        pub fn token<T>(&mut self) -> T
            where T: FromStr,
                  <T as FromStr>::Err: 'static + std::error::Error
        {
            self.try_token().unwrap()
        }
    }
}

use std::io::{stdin, stdout, BufRead, Write};
use io::Scanner;

fn main() {
    let stdin = stdin();
    solve(Scanner::new(stdin.lock()), stdout().lock());
}

const M: u64 = 1e9 as u64 + 7;

fn solve<R: BufRead, W: Write>(mut scan: Scanner<R>, mut output: W) {
    let n: u64 = scan.token();
    let k: u64 = scan.token();
    let k_1 = k - 1;
    let kp3 = mpow(k_1, n);
    let mut sum = mpow((mpow(k, n) + (M - kp3)) % M, n);
    let mut bcf = 1;
    let mut kp2 = 1;
    for i in 1..=n {
        bcf = (n - i + 1) * mpow(i, M - 2) % M * bcf % M;
        let kp1 = mpow(k, n - i);
        kp2 = kp2 * k_1 % M;
        sum = (sum + mpow(M - 1, i & 1) * bcf % M * mpow((kp1 * kp2 % M + (M - kp3)) % M, n) % M) % M;
    }
    writeln!(output, "{}", sum).unwrap();
}

pub fn mpow(mut base: u64, mut exp: u64) -> u64 {
    let mut result = 1;
    while exp > 0 {
        if exp & 1 == 1 {
            result = (result * base) % M;
        }
        exp >>= 1;
        base = (base * base) % M;
    }
    result
}

#[cfg(test)]
mod tests {
    use super::*;
    use helpers::t;

    #[test]
    fn example1() {
        t!("2 2\n", "7\n");
    }

    #[test]
    fn example2() {
        t!("123 456789\n", "689974806\n");
    }
}

// ---------- begin ModInt ----------
const MOD: u32 = 1_000_000_007;

#[derive(Clone, Copy)]
struct ModInt(u32);

impl std::ops::Add for ModInt {
    type Output = ModInt;
    fn add(self, rhs: ModInt) -> Self::Output {
        let mut d = self.0 + rhs.0;
        if d >= MOD {
            d -= MOD;
        }
        ModInt(d)
    }
}

impl std::ops::AddAssign for ModInt {
    fn add_assign(&mut self, rhs: ModInt) {
        *self = *self + rhs;
    }
}

impl std::ops::Sub for ModInt {
    type Output = ModInt;
    fn sub(self, rhs: ModInt) -> Self::Output {
        let mut d = self.0 + MOD - rhs.0;
        if d >= MOD {
            d -= MOD;
        }
        ModInt(d)
    }
}

impl std::ops::SubAssign for ModInt {
    fn sub_assign(&mut self, rhs: ModInt) {
        *self = *self - rhs;
    }
}

impl std::ops::Mul for ModInt {
    type Output = ModInt;
    fn mul(self, rhs: ModInt) -> Self::Output {
        ModInt((self.0 as u64 * rhs.0 as u64 % MOD as u64) as u32)
    }
}

impl std::ops::MulAssign for ModInt {
    fn mul_assign(&mut self, rhs: ModInt) {
        *self = *self * rhs;
    }
}

impl std::ops::Neg for ModInt {
    type Output = ModInt;
    fn neg(self) -> Self::Output {
        ModInt(if self.0 == 0 {0} else {MOD - self.0})
    }
}

/*
impl std::fmt::Display for ModInt {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}", self.0)
    }
}
*/

#[allow(dead_code)]
impl ModInt {
    pub fn new(n: u32) -> ModInt {
        ModInt(n % MOD)
    }
    pub fn zero() -> ModInt {
        ModInt(0)
    }
    pub fn one() -> ModInt {
        ModInt(1)
    }
    pub fn pow(self, mut n: u32) -> ModInt {
        let mut t = ModInt::one();
        let mut s = self;
        while n > 0 {
            if n & 1 == 1 {
                t *= s;
            }
            s *= s;
            n >>= 1;
        }
        t
    }
    pub fn inv(self) -> ModInt {
        self.pow(MOD - 2)
    }
    pub fn comb(n: u32, k: u32) -> ModInt {
        if k > n {
            return ModInt::zero();
        }
        let k = std::cmp::min(k, n - k);
        let mut nu = ModInt::one();
        let mut de = ModInt::one();
        for i in 0..k {
            nu *= ModInt(n - i);
            de *= ModInt(i + 1);
        }
        nu * de.inv()
    }
}

#[allow(dead_code)]
struct Precalc {
    inv: Vec<ModInt>,
    fact: Vec<ModInt>,
    ifact: Vec<ModInt>,
}

#[allow(dead_code)]
impl Precalc {
    pub fn new(n: usize) -> Precalc {
        let mut inv = vec![ModInt::one(); n + 1];
        let mut fact = vec![ModInt::one(); n + 1];
        let mut ifact = vec![ModInt::one(); n + 1];
        for i in 2..(n + 1) {
            inv[i] = -inv[MOD as usize % i] * ModInt(MOD / i as u32);
            fact[i] = fact[i - 1] * ModInt(i as u32);
            ifact[i] = ifact[i - 1] * inv[i];
        }
        Precalc {
            inv: inv,
            fact: fact,
            ifact: ifact,
        }
    }
    pub fn inv(&self, n: usize) -> ModInt {
        self.inv[n]
    }
    pub fn fact(&self, n: usize) -> ModInt {
        self.fact[n]
    }
    pub fn ifact(&self, n: usize) -> ModInt {
        self.ifact[n]
    }
    pub fn comb(&self, n: usize, k: usize) -> ModInt {
        if k > n {
            return ModInt::zero();
        }
        self.fact[n] * self.ifact[k] * self.ifact[n - k]
    }
}
// ---------- end ModInt ----------
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input! {
        n: usize,
        k: u32,
    }
    let mut ans = ModInt::zero();
    let pc = Precalc::new(n);
    for i in 0..=n {
        for j in 0..=n {
            let v = (n - i) * (n - j);
            let way = ModInt(k).pow(v as u32) * ModInt(k - 1).pow((n * n - v) as u32);
            ans += ModInt(MOD - 1).pow((i + j) as u32) * pc.comb(n, i) * pc.comb(n, j) * way;
        }
    }
    println!("{}", ans.0);
}

fn main() {
    run();
}

pub struct Scanner {
  buffer: Vec<String>
}

impl Scanner {
  pub fn new() -> Scanner {
    Scanner { buffer: Vec::new() }
  }

  pub fn next<T: std::str::FromStr>(&mut self) -> T {
    loop {
      if let Some(token) = self.buffer.pop() {
          return token.parse().ok().expect("Failed parse");
      }
      let mut input = String::new();
      std::io::stdin().read_line(&mut input).expect("Failed read");
      self.buffer = input.split_whitespace().rev().map(String::from).collect();
    }
  }
}

const MOD: u64 = 1_000_000_007;

fn bin_pow(mut a: u64, mut n: u64) -> u64 {
  let mut x: u64 = 1;
  while n > 0 {
    if (n & 1) == 1 {
      x = x * a % MOD;
    }
    a = a * a % MOD;
    n >>= 1;
  }
  return x;
}

fn rev(a: u64) -> u64 {
  return bin_pow(a, MOD - 2);
}

fn main() {
  let mut scan = Scanner::new();
  let n: usize = scan.next();
  let x: usize = scan.next();

  let mut f: Vec<u64> = vec![0; 1000];
  f[0] = 1;
  for i in 1..1000 {
    f[i] = f[i - 1] * (i as u64) % MOD;
  }

  let mut rf: Vec<u64> = vec![0; 1000];
  for i in 0..1000 {
    rf[i] = rev(f[i]);
  }

  let mut px: Vec<u64> = vec![0; 1000];
  px[0] = 1;
  for i in 1..1000 {
    px[i] = px[i - 1] * ((x-1) as u64) % MOD;
  }

  let c = |n, k|{ f[n] * rf[n-k] % MOD * rf[k] % MOD };

  let mut dp: Vec<Vec<u64>> = vec![vec![0; n + 1]; n + 1];
  dp[0][0] = 1;
  for ones_now in 1..(n+1) {
    for ones_before in 0..(ones_now+1) {
      let mut ways: u64 = 0;
      for place_non_one in 0..std::cmp::min(ones_before + 1, ones_now) {
        ways += px[place_non_one] * rf[place_non_one] % MOD * rf[ones_before - place_non_one] % MOD;
      }
      ways %= MOD;
      ways = ways * f[ones_before] % MOD;
      ways = ways * c(n-ones_before, ones_now-ones_before) % MOD;
      ways = ways * px[n-ones_now] % MOD;
      for i in 1..(n+1) {
        dp[i][ones_now] = (dp[i][ones_now] + dp[i-1][ones_before] * ways) % MOD;
      }
    }
  }

  println!("{}", dp[n][n]);
}


use std::io;
use std::cmp::max;

trait Substring {
    fn substring(&self, start: i32, len: i32) -> String;
}

impl Substring for String {

    fn substring(&self, start: i32, len: i32) -> String {
        self.chars().skip(start as usize).take(len as usize).collect()
    }
}

fn main() {

    let mut n: String = String::new();
    let mut inp: String = String::new();

    io::stdin().read_line(&mut n).unwrap();
    io::stdin().read_line(&mut inp).unwrap();

    let n: i32 = n.trim().parse().unwrap();

    let mut ans: Vec<_> = (0..n/2+1).filter(|&i: &i32| -> bool {
        inp.substring(0, i) == inp.substring(i, i)
    }).collect();

    let ans: i32 = ans.pop().unwrap();
    let display: i32 = n - max(ans-1, 0);

    println!("{}", display);
}

#![allow(unused_imports, unused_variables, dead_code, non_snake_case, unused_macros)]
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;
use std::iter::FromIterator;
fn getline() -> String {
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}
macro_rules ! readl { ( $ t : ty ) => { { let s = getline ( ) ; s . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,+ ) => { { let s = getline ( ) ; let mut iter = s . trim ( ) . split ( ' ' ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; }
macro_rules ! readlvec { ( $ t : ty ) => { { let s = getline ( ) ; let iter = s . trim ( ) . split ( ' ' ) ; iter . map ( | x | x . parse ( ) . unwrap ( ) ) . collect ::< Vec <$ t >> ( ) } } }
macro_rules ! mvec { ( $ v : expr , $ s : expr ) => { vec ! [ $ v ; $ s ] } ; ( $ v : expr , $ s : expr , $ ( $ t : expr ) ,* ) => { vec ! [ mvec ! ( $ v , $ ( $ t ) ,* ) ; $ s ] } ; }
macro_rules ! debug { ( $ x : expr ) => { println ! ( "{}: {:?}" , stringify ! ( $ x ) , $ x ) } }
fn printiter<'a, T>(v: &'a T)
where
    &'a T: std::iter::IntoIterator,
    <&'a T as std::iter::IntoIterator>::Item: std::fmt::Display,
{
    for (i, e) in v.into_iter().enumerate() {
        if i != 0 {
            print!(" ");
        }
        print!("{}", e);
    }
    println!("");
}
struct ContestPrinter {
    s: String,
}
impl ContestPrinter {
    fn new() -> ContestPrinter {
        ContestPrinter { s: String::new() }
    }
    fn print<T>(&mut self, x: T)
    where
        T: std::fmt::Display,
    {
        self.s.push_str(format!("{}", x).as_str());
    }
    fn println<T>(&mut self, x: T)
    where
        T: std::fmt::Display,
    {
        self.s.push_str(format!("{}\n", x).as_str());
    }
}
impl std::ops::Drop for ContestPrinter {
    fn drop(&mut self) {
        print!("{}", self.s);
    }
}
static MOD: i64 = 1e9 as i64 + 7;
fn is_max_i64(num: i64) -> bool {
    if num == i64::max_value() {
        true
    } else {
        false
    }
}

fn bfs(graph: &Vec<Vec<usize>>, start: usize) -> Vec<usize> {
    let mut visited: Vec<i32> = vec![-1; graph.len()];
    let mut prev: Vec<usize> = vec![0; graph.len()];
    prev[start] = usize::max_value();
    let mut q: VecDeque<usize> = VecDeque::new();
    visited[start] = 0;
    q.push_back(start);
    while !q.is_empty() {
        let &c_idx = q.front().unwrap();
        let c_cost = visited[c_idx];
        for n_idx in graph[c_idx].iter() {
            let c = visited[*n_idx];
            if c < 0 {
                let n_cost = c_cost + 1;
                visited[*n_idx] = n_cost;
                prev[*n_idx] = c_idx;
                q.push_back(*n_idx);
            }
        }
        q.pop_front();
    }
    prev
}

fn get_path(prev: Vec<usize>, goal: usize) -> Vec<usize> {
    let mut path = Vec::new();
    let mut c = goal;
    while c != usize::max_value() {
        path.push(c);
        c = prev[c];
    }
    path
}

fn main() {
    let mut pr = ContestPrinter::new();
    /*let (N, M, S, T) = readl!(usize, usize, usize, usize);
    let mut g: Vec<Vec<usize>> = vec![Vec::new(); N];
    for i in 0..M {
        let (a, b) = readl!(usize, usize);
        g[a-1].push(b-1);
        g[b-1].push(a-1);
    }

    let path = bfs(&g, S-1);
    let p_nodes = get_path(path, T-1);
    let p_set: HashSet<usize> = HashSet::from_iter(p_nodes.iter().cloned());
    let num = p_nodes.len();
    let mut ans = 0;
    for i in 0..N {
        ans += N - num;
        let mut cnt = 0;
        let on = p_set.contains(&i);
        for j in 0..g[i].len() {
            let idx = g[i][j];
            if on & !p_set.contains(&idx) {
                cnt += 1;
            }
        }
        ans -= cnt;
    }

    pr.println(ans);*/
    let N = readl!(usize);
    let s = readl!(String);

    let mut ans = 0;
    for i in 1..N/2+1 {
        let pr = &s[0..i];
        let co = &s[i..i+i];
        if pr == co { ans = i-1; };
    }

    pr.println(N - ans);
}


//spnauti-rusT
use std::io::*;
use std::str::{self,*};
use std::fmt::Debug;
#[allow(unused_imports)] use std::cmp::Ordering::{self,*};
#[allow(unused_imports)] use std::ops::{self,*};
#[allow(unused_imports)] use std::iter::{self,*};
#[allow(unused_imports)] use std::collections::*;
#[allow(unused_macros)]
macro_rules! m {
    ($c:tt, $x:expr, $y:expr) => {{
        let b = $y; let a = &mut $x;
        if b $c *a { *a = b; true } else { false }
    }};
}
#[allow(unused_macros)]
macro_rules! l {
    ($($v:ident),* = $i:ident.$f:ident $a:tt) => {
        $( let $v = $i.$f$a; )*
    };
    ($($v:ident),*:$t:ty = $i:ident.$f:ident $a:tt) => {
        $( let $v:$t = $i.$f$a; )*
    };
}
struct WordReader<'a> { it : SplitAsciiWhitespace<'a> }
#[allow(dead_code)]
impl<'a> WordReader<'a> {
    fn new<T: Read>(b: &mut String, mut r: T) -> WordReader {
        b.clear();
        r.read_to_string(b).ok();
        WordReader { it: b.split_ascii_whitespace() }
    }
    fn from_stdin(b: &mut String) -> WordReader {
        WordReader::new(b, stdin())
    }
    fn sl(&mut self) ->  &str { self.it.next().unwrap() }
    fn bs(&mut self) -> &[u8] { self.sl().as_bytes()    }
    fn s(&mut self) -> String { String::from(self.sl()) }
    fn i(&mut self) ->    i32 { self.p()                }
    fn f(&mut self) ->    f64 { self.p()                }
    fn u(&mut self) ->  usize { self.p()                }
    fn sk(&mut self, n: usize) { self.it.nth(n - 1); }
    fn ii(&mut self, n: usize) -> impl Iterator<Item=i32> {
        self.ip(n).into_iter()
    }
    fn vi(&mut self, n: usize) -> Vec<i32> {
        self.vp::<i32>(n)
    }
    fn p<T: FromStr>(&mut self) -> T where T::Err: Debug {
        self.sl().parse::<T>().unwrap()
    }
    fn ip<T: FromStr>(&mut self, n: usize) -> impl Iterator<Item=T> where T::Err: Debug {
        self.vp(n).into_iter()
    }
    fn vp<T: FromStr>(&mut self, n: usize) -> Vec<T> where T::Err: Debug {
        (0..n).map(|_| self.p()).collect()
    }
}
//------------------- End rusT

fn main() {
    let mut bin = String::new();
    let mut input = WordReader::from_stdin(&mut bin);

    l!(a,b = input.u());
    for i in a..=b {
        let mut x = i;
        let mut c = [0; 10];
        while x > 0 {
            c[x % 10] += 1;
            x /= 10;
        }
        if c.iter().max().unwrap() == &1 {
            println!("{}", i);
            return;
        }
    }
    println!("-1");
}

#[allow(unused_imports)]
use std::io::{BufReader, BufWriter, stdin, stdout, Write};
use std::cmp::{min, max};
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet, BinaryHeap};

fn check(mut x:i64) -> bool {
	let mut ch = vec![false; 10];
	while x > 0 {
		if ch[(x % 10) as usize] {
			return false;
		}
		ch[(x % 10) as usize] = true;
		x /= 10;
	}
	return true;
}

fn main() {
	let mut inp = my_input::default();
	let out = &mut BufWriter::new(stdout());
	let l:i64 = inp.scan::<i64>();
	let r:i64 = inp.scan::<i64>();
	for i in l..r+1 {
		if check(i) {
			writeln!(out, "{}", i);
			return;
		}
	}
	writeln!(out, "-1");
}

#[derive(Default)]
struct my_input {
	buffer: Vec<String>
}

impl my_input {
	fn scan<T: std::str::FromStr>(&mut self) -> T {
		loop {
			if let Some(token) = self.buffer.pop() {
				return token.parse().ok().expect("Parsing Error");
			}
			let mut s = String::new();
			stdin().read_line(&mut s).expect("Reading Error");
			self.buffer = s.split_whitespace().rev().map(String::from).collect();
		}
	}
}

use std::io::{Read,stdin};

fn main() {
    let mut buf = String::new();
    stdin().read_to_string(&mut buf).unwrap();
    let mut tok = buf.split_whitespace();
    let mut get = || tok.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }

    let l = get!(usize);
    let r = get!(usize);

    for x in l ..= r {
        let mut y = x;
        let mut f = vec![false; 10];
        let mut ok = true;
        while y > 0 {
            if f[y % 10] {
                ok = false;
                break;
            }
            f[y % 10] = true;
            y /= 10;
        }
        if ok {
            println!("{}", x);
            return;
        }
    }

    println!("-1");
}

use std::io::{self, BufRead, Write};
use std::str::{self, FromStr, SplitAsciiWhitespace};

fn main() {
    let stdin = io::stdin();
    solve(stdin.lock(), io::stdout());
}

type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;

struct Scanner<'a, R> {
    reader: R,
    buf_str: Vec<u8>,
    buf_iter: SplitAsciiWhitespace<'a>,
}

impl<R: BufRead> Scanner<'_, R> {
    pub fn new(reader: R) -> Self {
        Self {
            reader,
            buf_str: Vec::new(),
            buf_iter: "".split_ascii_whitespace(),
        }
    }

    fn try_token<T>(&mut self) -> Result<T>
        where T: FromStr,
              <T as FromStr>::Err: 'static + std::error::Error
    {
        loop {
            if let Some(token) = self.buf_iter.next() {
                return Ok(token.parse()?);
            }
            self.buf_str.clear();
            let bytes_read = self.reader
                .read_until(b'\n', &mut self.buf_str)?;
            if bytes_read == 0 {
                return Err(Box::new(io::Error::from(io::ErrorKind::UnexpectedEof)));
            }
            self.buf_iter = unsafe {
                let slice = str::from_utf8_unchecked(&self.buf_str);
                ::std::mem::transmute(slice.split_ascii_whitespace())
            }
        }
    }

    fn token<T>(&mut self) -> T
        where T: FromStr,
              <T as FromStr>::Err: 'static + std::error::Error
    {
        self.try_token().unwrap()
    }
}

fn solve<R: BufRead, W: Write>(input: R, mut output: W) {
    let mut scan = Scanner::new(input);

    let l: u32 = scan.token();
    let r: u32 = scan.token();
    let mut met;
    'numbers: for x in l..=r {
        met = [false; 10];
        let mut xx = x;
        while xx != 0 {
            let digit = (xx % 10) as usize;
            if met[digit] { continue 'numbers; }
            met[digit] = true;
            xx /= 10;
        }
        writeln!(output, "{}", x).unwrap();
        return;
    }
    writeln!(output, "-1").unwrap();
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn example1() {
        let inp = &b"121 130\n"[..];
        let mut out = String::new();
        solve(inp, unsafe { out.as_mut_vec() });
        assert_eq!(out, "123\n");
    }

    #[test]
    fn example2() {
        let inp = &b"98766 100000\n"[..];
        let mut out = String::new();
        solve(inp, unsafe { out.as_mut_vec() });
        assert_eq!(out, "-1\n");
    }

    #[test]
    fn badhead() {
        let inp = &b"110 119\n"[..];
        let mut out = String::new();
        solve(inp, unsafe { out.as_mut_vec() });
        assert_eq!(out, "-1\n");
    }

    #[test]
    fn t() {
        let inp = &b"1211 1240\n"[..];
        let mut out = String::new();
        solve(inp, unsafe { out.as_mut_vec() });
        assert_eq!(out, "1230\n");
    }
}

//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input! {
        l: usize,
        r: usize,
    }
    for x in l..=r {
        let s: Vec<char> = x.to_string().chars().collect();
        let k = s.len();
        let mut ok = true;
        for i in 0..k {
            for j in 0..i {
                if s[i] == s[j] {
                    ok = false;
                }
            }
        }
        if ok {
            println!("{}", x);
            return;
        }
    }
    println!("-1");
}

fn main() {
    run();
}

use std::io;

use std::collections::HashSet;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let input: Vec<u32> = buf.trim().split(' ').map(|x| x.parse().unwrap()).collect();
    let (left, right) = (input[0], input[1]);
    let res = (left..=right)
        .map(|x| {
            let s = x.to_string();
            (
                x.to_string(),
                s.chars().collect::<HashSet<_>>().len(),
                s.chars().count(),
            )
        })
        .find(|(_, len1, len2)| len1 == len2);
    let res = match res {
        Some(r) => r.0,
        None => (-1).to_string(),
    };
    println!("{}", res);
}

struct Scan {
    buffer: std::collections::VecDeque<String>,
}

impl Scan {
    fn new() -> Scan {
        Scan {
            buffer: std::collections::VecDeque::new(),
        }
    }

    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop_front() {
                break token.parse::<T>().ok().unwrap();
            }
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).expect("Fail to read");
            self.buffer = line.split_whitespace().map(String::from).collect();
        }
    }
}

fn is_good(x: usize) -> bool {
    let mut isused: [bool; 10] = [false; 10];
    let mut a = x;
    while a > 0 {
        let dig = a % 10;
        a /= 10;
        if isused[dig] {
            return false;
        }
        isused[dig] = true;
    }
    return true;
}

fn _main() {
    let mut scan = Scan::new();
    let l: usize = scan.next();
    let r: usize = scan.next();
    for i in l..=r {
        if is_good(i) {
            println!("{}", i);
            return;
        }
    }
    println!("-1");
}

fn main() {
    std::thread::Builder::new()
        .stack_size(1 << 23)
        .spawn(_main)
        .unwrap()
        .join()
        .unwrap();
}

fn ud(mut a: i32) -> bool {
    let mut m = 0;
    while a != 0 {
        let c = 1 << (a % 10);
        if m & c != 0 {
            return false;
        }
        m |= c;
        a /= 10;
    }
    true
}

fn solve(a: i32, b: i32) -> i32 {
    for i in a..=b {
        if ud(i) {
            return i;
        }
    }
    -1
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut it = buf.trim().split_whitespace();
    println!(
        "{}",
        solve(
            it.next().unwrap().parse().unwrap(),
            it.next().unwrap().parse().unwrap()
        )
    );
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_canonical() {
        assert_eq!(solve(121, 130), 123);
        assert_eq!(solve(98766, 100000), -1);
    }
}

use std::io;
use std::collections::HashSet;

// type Matrix = Vec<Vec<char>>;

fn read_line() -> String {
    let mut input_line = String::new();
    io::stdin().read_line(&mut input_line).unwrap();
    return String::from(input_line.trim());
}

fn read_line_vec() -> Vec<i64> {
    return read_line().split(' ')
        .map(|s| s.parse().unwrap())
        .collect();
}

fn read_line_pair() -> (i64, i64) {
    let vec = read_line_vec();
    return (vec[0], vec[1]);
}

fn is_diff(n: i64) -> bool {
    let mut nn = n;
    let mut hs = HashSet::new();
    while nn > 0 {
        let ni = nn % 10;
        nn /= 10;
        if hs.contains(&ni) {
            return false;
        }
        hs.insert(ni);
    }
    return true;
}

fn has(l: i64, r: i64) -> Option<i64> {
    for i in l..(r+1) {
        if is_diff(i) {
            return Some(i);
        }
    }
    return None;
}

fn main() {
    let (l, r) = read_line_pair();

    // let r = is_diff(1101231);

    match has(l, r) {
        Some(n) => println!("{}", n),
        None => println!("-1")
    }

    // println!("{:?}", r);

}

#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}

macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

fn ok(a: usize) -> bool {
    let mut a = a;
    let mut d = vec![];
    while a > 0 {
        d.push(a % 10);
        a /= 10;
    }
    use std::collections::HashSet;
    let s : HashSet<_> = d.iter().collect();
    d.len() == s.len()
}

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let m: usize = sc.cin();
    for a in n..m+1 {
        if ok(a) {
            put!(a);
            return;
        }
    }
    put!(-1);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}

#[allow(unused_imports)]
use std::cmp::{max, min};
use std::collections::HashSet;

type GenError = Box<dyn std::error::Error>;
type GenResult<T> = Result<T, GenError>;

struct Reader {}

impl Reader {
    #[allow(unused)]
    fn read_string() -> GenResult<String> {
        let mut string: String = String::new();
        std::io::stdin().read_line(&mut string)?;
        Ok(string.trim().to_string())
    }

    #[allow(unused)]
    fn read_tokens() -> GenResult<Vec::<String>> {
        let mut string: String = String::new();
        std::io::stdin().read_line(&mut string)?;
        let mut v = Vec::new();
        for value in string.split_whitespace() {
            v.push(value.to_string());
        }
        Ok(v)
    }
}

fn main() {
    let tokens = Reader::read_tokens().unwrap();
    let n: i32 = tokens[0].parse().unwrap();
    let m: i32 = tokens[1].parse().unwrap();
    for value in n .. m + 1 {
        let mut chars = HashSet::new();
        let string = value.to_string();
        for ch in string.chars(){
            chars.insert(ch);
        }
        if chars.len() == string.len() {
            println!("{}", string);
            return;
        }
    }
    println!("{}", -1);
}

use std::io;
use std::collections::HashSet;

// type Matrix = Vec<Vec<char>>;

fn read_line() -> String {
    let mut input_line = String::new();
    io::stdin().read_line(&mut input_line).unwrap();
    return String::from(input_line.trim());
}

fn read_line_vec() -> Vec<i64> {
    return read_line().split(' ')
        .map(|s| s.parse().unwrap())
        .collect();
}

fn read_line_pair() -> (i64, i64) {
    let vec = read_line_vec();
    return (vec[0], vec[1]);
}

fn is_diff(n: i64) -> bool {
    let mut nn = n;
    let mut hs = HashSet::new();
    while nn > 0 {
        let ni = nn % 10;
        nn /= 10;
        if hs.contains(&ni) {
            return false;
        }
        hs.insert(ni);
    }
    return true;
}

fn has(l: i64, r: i64) -> Option<i64> {
    for i in l..r {
        if is_diff(i) {
            return Some(i);
        }
    }
    return None;
}

fn main() {
    let (l, r) = read_line_pair();

    // let r = is_diff(1101231);

    match has(l, r) {
        Some(n) => println!("{}", n),
        None => println!("-1")
    }

    // println!("{:?}", r);

}