Xâu min

View as PDF




Time limit:
Scratch 5.0s

Problem types
Points: 1300 (p) Time limit: 1.0s Memory limit: 256M Input: stdin Output: stdout

Cho xâu \(S\) chứa các kí tự \(1 \ldots 9\) (\(|S| \leq 1000\) kí tự) và số nguyên \(K\) (\(1 \leq K \leq |S|\)). (\(|S|\) độ dài của xâu \(S\))

Yêu cầu: Chọn \(K\) kí tự trong xâu \(S\) theo thứ tự ban đầu để tạo thành số \(X\) gồm \(K\) chữ số có giá trị bé nhất.

Input

  • Dòng 1: Ghi số \(K\).
  • Dòng 2: Ghi xâu \(S\).

Output

  • Ghi một số duy nhất \(X\).

Example

Test 1

Input
3
89678982 
Output
672

Comments

There are no comments at the moment.