package main

import (
	"bufio"
	"fmt"
	"os"
)

func slove(n, k int, an []int) []int {
	bn := make([]int, n)
	copy(bn, an)

	min_down, min_up := n, n

	for i := 0; i+k < n; i++ {
		if min_down == n && an[i+k] > an[i] {
			min_down = i + k
		} else if min_up == n && an[i+k] < an[i] {
			min_up = i + k
		}
		bn[i+k] = bn[i]
	}

	if min_up <= min_down {
		return bn
	} else {
		//fmt.Printf("%d, %d\n", min_up, min_down)
		for i := k - 1; i >= 0; i-- {
			if i >= min_down {
				continue
			}
			if an[i] != 9 {
				bn[i] = an[i] + 1
				break
			} else {
				bn[i] = 0
			}
		}
		for i := 0; i+k < n; i++ {
			bn[i+k] = bn[i]
		}
		return bn
	}

}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	for {
		var n, k int
		_, err := fmt.Fscanln(in, &n, &k)
		if err != nil {
			break
		}

		var a string
		fmt.Fscanln(in, &a)

		an := make([]int, n)

		for i := 0; i < n; i++ {
			an[i] = int(a[i] - '0')
		}

		bn := slove(n, k, an)

		fmt.Fprintln(out, n)
		for _, b := range bn {
			fmt.Fprintf(out, "%d", b)
		}

		fmt.Fprintln(out)
	}
	out.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

const N = 200100
var n, k int
var s string
var a[N] int
var b[N] int

func main()  {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	fmt.Fscanf(reader, "%d %d\n", &n, &k)

	fmt.Fscanf(reader, "%s", &s)
	for i := 0; i < n; i++ {
		a[i + 1] = int(s[i] - '0')
	}

	for i := 1; i <= k; i++ {
		b[i] = a[i]
	}
	for i := k + 1; i <= n; i++ {
		b[i] = b[i - k]
	}

	var gte = true

	for i := 1; i <= n; i++ {
		if a[i] != b[i] {
			if b[i] < a[i] {
				gte = false
			}
			break
		}
	}

	if !gte {
		for i := k; i >= 1; i-- {
			if b[i] == 9 {
				b[i] = 0
			} else {
				b[i]++
				break
			}
		}
		for i := k + 1; i <= n; i++ {
			b[i] = b[i - k]
		}
	}

	fmt.Fprintf(writer, "%d\n", n)
	for i := 1; i <= n; i++ {
		fmt.Fprintf(writer, "%d", b[i])
	}
}

/*
URL:
https://codeforces.com/contest/1269/problem/C
*/

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var n, k int
var A []rune

func main() {
	n, k = ReadInt2()
	A = ReadRuneSlice()

	isBeau := true
	for i := 0; i < n; i++ {
		if i+k < n {
			if A[i] != A[i+k] {
				isBeau = false
				break
			}
		} else {
			break
		}
	}
	if isBeau {
		fmt.Println(len(A))
		fmt.Println(string(A))
		return
	}

	B := make([]rune, n)
	for i := 0; i < n; i++ {
		B[i] = 'x'
	}

	// iは起点
	for i := 0; i < k; i++ {
		digit := A[i]

		// すでに埋まっていたら抜ける
		// if B[i] != 'x' {
		// 	break
		// }

		// jは飛び飛び
		for j := i; j < n; j += k {
			B[j] = digit
		}
	}
	// PrintDebug("%s\n", string(B))

	isSmall := false
	for i := 0; i < n; i++ {
		if A[i] == B[i] {
			continue
		} else if A[i] < B[i] {
			break
		} else {
			isSmall = true
			break
		}
	}
	if !isSmall {
		fmt.Println(len(B))
		fmt.Println(string(B))
		return
	}

	// 大きくなるように正しく調整する
	for i := k - 1; i >= 0; i-- {
		if B[i] == '9' {
			// iからk飛びで0に更新
			for j := i; j < n; j += k {
				B[j] = '0'
			}
		} else {
			// iからk飛びで更新
			for j := i; j < n; j += k {
				B[j]++
			}
			break
		}
	}

	fmt.Println(len(B))
	fmt.Println(string(B))
}

/*******************************************************************/

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func slove(n, k int, an []int) []int {
	bn := make([]int, n)
	copy(bn, an)

	min_down, min_up := n, n

	for i := 0; i+k < n; i++ {
		if min_down == n && an[i+k] > an[i] {
			min_down = i + k
		} else if min_up == n && an[i+k] < an[i] {
			min_up = i + k
		}
		bn[i+k] = bn[i]
	}

	if min_up <= min_down {
		return bn
	} else {
		//fmt.Printf("%d, %d\n", min_up, min_down)
		for i := k - 1; i >= 0; i-- {
			if i >= min_down {
				continue
			}
			if an[i] != 9 {
				bn[i] = an[i] + 1
				break
			} else {
				bn[i] = 0
			}
		}
		for i := 0; i+k < n; i++ {
			bn[i+k] = bn[i]
		}
		return bn
	}

}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	for {
		var n, k int
		_, err := fmt.Fscanln(in, &n, &k)
		if err != nil {
			break
		}

		var a string
		fmt.Fscanln(in, &a)

		an := make([]int, n)

		for i := 0; i < n; i++ {
			an[i] = int(a[i] - '0')
		}

		bn := slove(n, k, an)

		fmt.Fprintln(out, n)
		for _, b := range bn {
			fmt.Fprintf(out, "%d", b)
		}

		fmt.Fprintln(out)
		out.Flush()
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var n, k int
var a string

func add(b string) string {
	bb := []byte(b)
	cnt := k - 1
	for cnt >= 0 {
		if bb[cnt] != '9' {
			bb[cnt]++
			break
		} else {
			bb[cnt] = '0'
		}
		cnt--
	}
	return string(bb)
}

func main() {
	stdin := os.Stdin
	reader := bufio.NewReaderSize(stdin, 1024*1024)
	fmt.Fscanf(reader, "%d %d\n", &n, &k)
	fmt.Fscanf(reader, "%s", &a)

	b := ""
	for len(b) < n {
		b += a[0:k]
	}
	b = b[0:n]

	if strings.Compare(a, b) == 1 {
		a = a[0:k]
		a = add(a)
		b = ""
		for len(b) < n {
			b += a
		}
		b = b[0:n]
	}

	fmt.Println(len(b))
	fmt.Println(b)
	return
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"strconv"
)

// -----------------------------------------------------------------------------

// IO helper functions

// Returns next token from input.  It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]byte, error)
var nextLine func() ([]byte, error)

// Holds a buffer for output.  It must be initialized by SetOutput().
// All IO fucntions (read*() and [e]print*()) should write to OutputWriter
// instead of this.
var OutputBuffer *bufio.Writer

// Holds an io.Writer.  It must be initialized by SetOutput()
var OutputWriter io.Writer

// Set IO functions for interactive input/output.
func SetInteractive(w io.Writer, r io.Reader) {
	SetUnbefferedInput(r)
	OutputBuffer = nil
	OutputWriter = w
}

// Setup OutputBuffer and OutputWriter.
func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

// Flushes OutputBuffer
func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

// Returns true if c is a white space
func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

func IsNewLine(c byte) bool {
	switch c {
	case '\n', '\r':
		return true
	}
	return false
}

// Setup nextToken with input buffer.
func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial

	restLn := func() ([]byte, error) {
		for i < len(b) && IsNewLine(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsNewLine(b[i]) {
			i++
		}
		return b[j:i], nil
	}

	initialLn := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextLine = restLn
		return restLn()
	}
	nextLine = initialLn
}

// Setup nextToken without input buffer.
func SetUnbefferedInput(r io.Reader) {
	buf := bufio.NewReader(r)
	var b []byte

	var i int
	nextToken = func() ([]byte, error) {
		var err error
		if i == len(b) {
			b, err = buf.ReadBytes('\n')
			if err != nil {
				return nil, err
			}
			i = 0
			j := len(b) - 1
			for 0 <= j && IsSpace(b[j]) {
				j--
			}
			b = b[0 : j+1]
		}
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
}

// -----------------------------------------------------------------------------

// IO functions

// Reads next token and return it as []byte
func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b
}

// Reads next token and return it as string
func reads() string {
	return string(readb())
}

// Read next line as []byte
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b
}

// Read next line as string
func readsln() string {
	return string(readbln())
}

// Reads next token and return it as int64
func readll() int64 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// Reads next token and return it as int
func readi() int {
	return int(readll())
}

// Reads next token and return it as float64
func readf() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// Write args to OutputWriter with the format f
func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(OutputWriter, f, args...)
}

// Write args to OutputWriter without format
func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(OutputWriter, args...)
}

// Write args to stderr with the format f
func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// Write args to stderr without format
func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// -----------------------------------------------------------------------------

// Simple math functions

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minll(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxll(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absll(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func gcdll(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcdll(b, a%b)
}

// set up IO functions
func init() {
	// for non-interactive
	SetInput(os.Stdin)
	SetOutput(os.Stdout)

	// Enable below when interactive.  Its ok to leave above intact.
	// SetInteractive(os.Stdout, os.Stdin)
}

func main() {
	defer Flush()

	n := readi()
	k := readi()
	b := readb()
	a := make([]int, n)
	for i := range a {
		a[i] = int(b[i] - '0')
	}

	x := a[:k]
	ok := true
outer:
	for r := k; r < n; r += k {
		y := a[r:min(n, r+k)]
		x2 := x[:len(y)]
		for j := range y {
			if y[j] < x2[j] {
				break outer
			} else if x2[j] < y[j] {
				ok = false
				break outer
			}
		}
	}

	if !ok {
		for i, j := 0, len(x)-1; i < j; i, j = i+1, j-1 {
			x[i], x[j] = x[j], x[i]
		}
		for i := 0; i < len(x); i++ {
			x[i]++
			if x[i] == 10 {
				x[i] = 0
			} else {
				break
			}
		}
		for i, j := 0, len(x)-1; i < j; i, j = i+1, j-1 {
			x[i], x[j] = x[j], x[i]
		}
	}

	var ans []int
	for len(ans) < n {
		ans = append(ans, x...)
	}
	ans = ans[:n]
	println(n)
	for i := range ans {
		printf("%d", ans[i])
	}
	println()
}

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60
const INF_INT32 = math.MaxInt32
const INF_BIT30 = 1 << 30

var n, k int
var A []rune

func main() {
	n, k = ReadInt2()
	A = ReadRuneSlice()

	isBeau := true
	for i := 0; i < n; i++ {
		if i+k < n {
			if A[i] != A[i+k] {
				isBeau = false
				break
			}
		} else {
			break
		}
	}
	if isBeau {
		fmt.Println(len(A))
		fmt.Println(string(A))
		return
	}

	B := make([]rune, n)
	for i := 0; i < n; i++ {
		B[i] = 'x'
	}

	// iは起点
	for i := 0; i < k; i++ {
		digit := A[i]

		// すでに埋まっていたら抜ける
		// if B[i] != 'x' {
		// 	break
		// }

		// jは飛び飛び
		for j := i; j < n; j += k {
			B[j] = digit
		}
	}
	// PrintDebug("%s\n", string(B))

	isSmall := false
	for i := 0; i < n; i++ {
		if A[i] == B[i] {
			continue
		} else if A[i] < B[i] {
			break
		} else {
			isSmall = true
			break
		}
	}
	if !isSmall {
		fmt.Println(len(B))
		fmt.Println(string(B))
		return
	}

	// 大きくなるように正しく調整する
	for i := k - 1; i >= 0; i-- {
		if B[i] == '9' {
			// iからk飛びで0に更新
			for j := i; j < n; j += k {
				B[j] = '0'
			}
		} else {
			// iからk飛びで更新
			for j := i; j < n; j += k {
				B[j]++
			}
			break
		}
	}

	fmt.Println(len(B))
	fmt.Println(string(B))
}

/*
- まずは全探索を検討しましょう
- MODは最後にとりましたか？
- ループを抜けた後も処理が必要じゃありませんか？
- 和・積・あまりを求められたらint64が必要ではありませんか？
- いきなりオーバーフローはしていませんか？
	- MOD取る系はint64必須ですよ？
*/

/*
ASCII code

ASCII   10進数  ASCII   10進数  ASCII   10進数
!       33      "       34      #       35
$       36      %       37      &       38
'       39      (       40      )       41
*       42      +       43      ,       44
-       45      .       46      /       47
0       48      1       49      2       50
3       51      4       52      5       53
6       54      7       55      8       56
9       57      :       58      ;       59
<       60      =       61      >       62
?       63      @       64      A       65
B       66      C       67      D       68
E       69      F       70      G       71
H       72      I       73      J       74
K       75      L       76      M       77
N       78      O       79      P       80
Q       81      R       82      S       83
T       84      U       85      V       86
W       87      X       88      Y       89
Z       90      [       91      \       92
]       93      ^       94      _       95
`       96      a       97      b       98
c       99      d       100     e       101
f       102     g       103     h       104
i       105     j       106     k       107
l       108     m       109     n       110
o       111     p       112     q       113
r       114     s       115     t       116
u       117     v       118     w       119
x       120     y       121     z       122
{       123     |       124     }       125
~       126             127
*/

/*******************************************************************/

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)

	var n, k int
	fmt.Fscan(in, &n)
	fmt.Fscanln(in, &k)

	x := make([]byte, n)
	for i := 0; i < n; i++ {
		b, _ := in.ReadByte()

		x[i] = b - '0'
	}

	for i := 0; i < n-k; i++ {
		if x[i+k] != x[i] {
			if x[i+k] < x[i] {
				for j := i + k ; j < n; j++ {
					x[j] = x[j-k]
				}
				i -=k
				if i < 0 {
					i = 0
				}
			} else {
				steps := 1
				x[i+k-1]++
				for j := i + k - 1; j > 0; j-- {
					if x[j] >= 10 {
						x[j] -= 10
						x[j-1]++
						steps = i - j + 1 + k
					}
				}

				for j := i + k; j < n; j++ {
					x[j] = x[j-k]
				}

				i -= steps + 1
				if i < -1 {
					i = -1
				}
			}
		}
	}

	fmt.Fprintln(out, len(x))
	for i := 0; i < len(x); i++ {
		fmt.Fprint(out, x[i])
	}

	out.Flush()
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	"strings"
)

// github.com/EndlessCheng/codeforces-go
func CF1268A(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var n, k int
	var s string
	Fscan(in, &n, &k, &s)
	base := s[:k]
o:
	for i := k; i < n; i += k {
		t := s[i:]
		if i+k <= n {
			t = s[i : i+k]
		}
		for j := range t {
			if t[j] != base[j] {
				if t[j] > base[j] {
					b := []byte(base)
					for j := k - 1; j >= 0; j-- {
						if b[j] < '9' {
							b[j]++
							break
						}
						b[j] = '0'
					}
					base = string(b)
				}
				break o
			}
		}
	}
	Fprintln(out, n)
	Fprintln(out, strings.Repeat(base, n/k)+base[:n%k])
}

func main() { CF1268A(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	"fmt"
	"os"
)

func slove(n, k int, an []int) []int {
	bn := make([]int, n)
	copy(bn, an)

	min_down, min_up := n, n

	for i := 0; i+k < n; i++ {
		if min_down == n && an[i+k] > an[i] {
			min_down = i + k
		} else if min_up == n && an[i+k] < an[i] {
			min_up = i + k
		}
		bn[i+k] = bn[i]
	}

	if min_up <= min_down {
		return bn
	} else {
		bn[min_down-1] = an[min_down-1] + 1
		for i := 0; i+k < n; i++ {
			bn[i+k] = bn[i]
		}
		return bn
	}

}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	for {
		var n, k int
		_, err := fmt.Fscanln(in, &n, &k)
		if err != nil {
			break
		}

		var a string
		fmt.Fscanln(in, &a)

		an := make([]int, n)

		for i := 0; i < n; i++ {
			an[i] = int(a[i] - '0')
		}

		bn := slove(n, k, an)

		fmt.Fprintln(out, n)
		for _, b := range bn {
			fmt.Fprintf(out, "%d", b)
		}

		fmt.Fprintln(out)
		out.Flush()
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func slove(n, k int, an []int) []int {
	bn := make([]int, n)
	copy(bn, an)

	min_down, min_up := n, n

	for i := 0; i+k < n; i++ {
		if min_down == n && an[i+k] > an[i] {
			min_down = i + k
		} else if min_up == n && an[i+k] < an[i] {
			min_up = i + k
		}
		bn[i+k] = bn[i]
	}

	//fmt.Printf("%d, %d\n", min_up, min_down)
	if min_up <= min_down {
		return bn
	} else {
		for i := min_down - 1; i >= 0; i-- {
			if an[i] != 9 {
				bn[i] = an[i] + 1
				break
			}
		}
		for i := 0; i+k < n; i++ {
			bn[i+k] = bn[i]
		}
		return bn
	}

}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	for {
		var n, k int
		_, err := fmt.Fscanln(in, &n, &k)
		if err != nil {
			break
		}

		var a string
		fmt.Fscanln(in, &a)

		an := make([]int, n)

		for i := 0; i < n; i++ {
			an[i] = int(a[i] - '0')
		}

		bn := slove(n, k, an)

		fmt.Fprintln(out, n)
		for _, b := range bn {
			fmt.Fprintf(out, "%d", b)
		}

		fmt.Fprintln(out)
		out.Flush()
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func slove(n, k int, an []int) []int {
	bn := make([]int, n)
	copy(bn, an)

	min_down, min_up := n, n

	for i := 0; i+k < n; i++ {
		if min_down == n && an[i+k] > an[i] {
			min_down = i + k
		} else if min_up == n && an[i+k] < an[i] {
			min_up = i + k
		}
		bn[i+k] = bn[i]
	}

	//fmt.Printf("%d, %d\n", min_up, min_down)
	if min_up <= min_down {
		return bn
	} else {
		for i := min_down - 1; i >= 0; i-- {
			if an[i] != 9 {
				bn[i] = an[i] + 1
				break
			} else {
				bn[i] = 0
			}
		}
		for i := 0; i+k < n; i++ {
			bn[i+k] = bn[i]
		}
		return bn
	}

}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	for {
		var n, k int
		_, err := fmt.Fscanln(in, &n, &k)
		if err != nil {
			break
		}

		var a string
		fmt.Fscanln(in, &a)

		an := make([]int, n)

		for i := 0; i < n; i++ {
			an[i] = int(a[i] - '0')
		}

		bn := slove(n, k, an)

		fmt.Fprintln(out, n)
		for _, b := range bn {
			fmt.Fprintf(out, "%d", b)
		}

		fmt.Fprintln(out)
		out.Flush()
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var n, k, a int

func check(a int) bool {
	mp := make(map[int]int)
	cnt := 0
	for a != 0 {
		if cnt < k {
			mp[cnt] = a % 10
		} else if mp[cnt%k] != a%10 {
			return false
		}
		cnt++
		a /= 10
	}
	return true
}

func main() {
	stdin := os.Stdin
	reader := bufio.NewReaderSize(stdin, 1024*1024)
	fmt.Fscanf(reader, "%d %d\n%d", &n, &k, &a)
	for {
		if check(a) {
			fmt.Println(len(strconv.Itoa(a)))
			fmt.Println(a)
			return
		}
		a++
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var n, k, a int

func check(a int) bool {
	mp := make(map[int]int)
	cnt := 0
	for a != 0 {
		if cnt < k {
			mp[cnt] = a % 10
		} else if mp[cnt%k] != a%10 {
			return false
		}
		cnt++
		a /= 10
	}
	return true
}

func main() {
	stdin := os.Stdin
	reader := bufio.NewReaderSize(stdin, 1024*1024)
	fmt.Fscanf(reader, "%d %d\n%d", &n, &k, &a)
	for {
		if check(a) {
			fmt.Println(a)
			return
		}
		a++
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var n, k int
var a string

func add(b string) string {
	bb := []byte(b)
	cnt := k - 1
	for cnt >= 0 {
		if bb[cnt] != '9' {
			bb[cnt]++
			break
		} else {
			bb[cnt] = '0'
		}
	}
	return string(bb)
}

func main() {
	stdin := os.Stdin
	reader := bufio.NewReaderSize(stdin, 1024*1024)
	fmt.Fscanf(reader, "%d %d\n", &n, &k)
	fmt.Fscanf(reader, "%s", &a)

	b := ""
	for len(b) < n {
		b += a[0:k]
	}
	b = b[0:n]

	if strings.Compare(a, b) == 1 {
		a = a[0:k]
		a = add(a)
		b = ""
		for len(b) < n {
			b += a
		}
		b = b[0:n]
	}

	fmt.Println(len(b))
	fmt.Println(b)
	return
}

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60
const INF_INT32 = math.MaxInt32
const INF_BIT30 = 1 << 30

var n, k int
var A []rune

func main() {
	n, k = ReadInt2()
	A = ReadRuneSlice()

	isBeau := true
	for i := 0; i < n; i++ {
		if i+k < n {
			if A[i] != A[i+k] {
				isBeau = false
				break
			}
		} else {
			break
		}
	}
	if isBeau {
		fmt.Println(string(A))
		return
	}

	B := make([]rune, n)
	for i := 0; i < n; i++ {
		B[i] = 'x'
	}

	isSmall := false
	// iは起点
	for i := 0; i < n; i++ {
		digit := A[i]

		// すでに埋まっていたら抜ける
		if B[i] != 'x' {
			break
		}

		// jは飛び飛び
		for j := i; j < n; j += k {
			B[j] = digit

			if digit < A[j] {
				isSmall = true
			}
		}
	}
	// PrintDebug("%s\n", string(B))

	if !isSmall {
		fmt.Println(string(B))
		return
	}

	// 大きくなるように正しく調整する
	for i := k - 1; i >= 0; i-- {
		if B[i] == '9' {
			// iからk飛びで0に更新
			for j := i; j < n; j += k {
				B[j] = '0'
			}
		} else {
			// iからk飛びで更新
			for j := i; j < n; j += k {
				B[j]++
			}
			break
		}
	}

	fmt.Println(string(B))
}

/*
- まずは全探索を検討しましょう
- MODは最後にとりましたか？
- ループを抜けた後も処理が必要じゃありませんか？
- 和・積・あまりを求められたらint64が必要ではありませんか？
- いきなりオーバーフローはしていませんか？
	- MOD取る系はint64必須ですよ？
*/

/*
ASCII code

ASCII   10進数  ASCII   10進数  ASCII   10進数
!       33      "       34      #       35
$       36      %       37      &       38
'       39      (       40      )       41
*       42      +       43      ,       44
-       45      .       46      /       47
0       48      1       49      2       50
3       51      4       52      5       53
6       54      7       55      8       56
9       57      :       58      ;       59
<       60      =       61      >       62
?       63      @       64      A       65
B       66      C       67      D       68
E       69      F       70      G       71
H       72      I       73      J       74
K       75      L       76      M       77
N       78      O       79      P       80
Q       81      R       82      S       83
T       84      U       85      V       86
W       87      X       88      Y       89
Z       90      [       91      \       92
]       93      ^       94      _       95
`       96      a       97      b       98
c       99      d       100     e       101
f       102     g       103     h       104
i       105     j       106     k       107
l       108     m       109     n       110
o       111     p       112     q       113
r       114     s       115     t       116
u       117     v       118     w       119
x       120     y       121     z       122
{       123     |       124     }       125
~       126             127
*/

/*******************************************************************/

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60
const INF_INT32 = math.MaxInt32
const INF_BIT30 = 1 << 30

var n, k int
var A []rune

func main() {
	n, k = ReadInt2()
	A = ReadRuneSlice()

	isBeau := true
	for i := 0; i < n; i++ {
		if i+k < n {
			if A[i] != A[i+k] {
				isBeau = false
				break
			}
		} else {
			break
		}
	}
	if isBeau {
		fmt.Println(len(A))
		fmt.Println(string(A))
		return
	}

	B := make([]rune, n)
	for i := 0; i < n; i++ {
		B[i] = 'x'
	}

	isSmall := false
	// iは起点
	for i := 0; i < n; i++ {
		digit := A[i]

		// すでに埋まっていたら抜ける
		if B[i] != 'x' {
			break
		}

		// jは飛び飛び
		for j := i; j < n; j += k {
			B[j] = digit

			if digit < A[j] {
				isSmall = true
			}
		}
	}
	// PrintDebug("%s\n", string(B))

	if !isSmall {
		fmt.Println(len(B))
		fmt.Println(string(B))
		return
	}

	// 大きくなるように正しく調整する
	for i := k - 1; i >= 0; i-- {
		if B[i] == '9' {
			// iからk飛びで0に更新
			for j := i; j < n; j += k {
				B[j] = '0'
			}
		} else {
			// iからk飛びで更新
			for j := i; j < n; j += k {
				B[j]++
			}
			break
		}
	}

	fmt.Println(len(B))
	fmt.Println(string(B))
}

/*
- まずは全探索を検討しましょう
- MODは最後にとりましたか？
- ループを抜けた後も処理が必要じゃありませんか？
- 和・積・あまりを求められたらint64が必要ではありませんか？
- いきなりオーバーフローはしていませんか？
	- MOD取る系はint64必須ですよ？
*/

/*
ASCII code

ASCII   10進数  ASCII   10進数  ASCII   10進数
!       33      "       34      #       35
$       36      %       37      &       38
'       39      (       40      )       41
*       42      +       43      ,       44
-       45      .       46      /       47
0       48      1       49      2       50
3       51      4       52      5       53
6       54      7       55      8       56
9       57      :       58      ;       59
<       60      =       61      >       62
?       63      @       64      A       65
B       66      C       67      D       68
E       69      F       70      G       71
H       72      I       73      J       74
K       75      L       76      M       77
N       78      O       79      P       80
Q       81      R       82      S       83
T       84      U       85      V       86
W       87      X       88      Y       89
Z       90      [       91      \       92
]       93      ^       94      _       95
`       96      a       97      b       98
c       99      d       100     e       101
f       102     g       103     h       104
i       105     j       106     k       107
l       108     m       109     n       110
o       111     p       112     q       113
r       114     s       115     t       116
u       117     v       118     w       119
x       120     y       121     z       122
{       123     |       124     }       125
~       126             127
*/

/*******************************************************************/

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60
const INF_INT32 = math.MaxInt32
const INF_BIT30 = 1 << 30

var n, k int
var A []rune

func main() {
	n, k = ReadInt2()
	A = ReadRuneSlice()

	isBeau := true
	for i := 0; i < n; i++ {
		if i+k < n {
			if A[i] != A[i+k] {
				isBeau = false
				break
			}
		} else {
			break
		}
	}
	if isBeau {
		fmt.Println(len(A))
		fmt.Println(string(A))
		return
	}

	B := make([]rune, n)
	for i := 0; i < n; i++ {
		B[i] = 'x'
	}

	// iは起点
	for i := 0; i < n; i++ {
		digit := A[i]

		// すでに埋まっていたら抜ける
		if B[i] != 'x' {
			break
		}

		// jは飛び飛び
		for j := i; j < n; j += k {
			B[j] = digit
		}
	}
	// PrintDebug("%s\n", string(B))

	isSmall := false
	for i := 0; i < n; i++ {
		if A[i] > B[i] {
			isSmall = true
			break
		}
	}
	if !isSmall {
		fmt.Println(len(B))
		fmt.Println(string(B))
		return
	}

	// 大きくなるように正しく調整する
	for i := k - 1; i >= 0; i-- {
		if B[i] == '9' {
			// iからk飛びで0に更新
			for j := i; j < n; j += k {
				B[j] = '0'
			}
		} else {
			// iからk飛びで更新
			for j := i; j < n; j += k {
				B[j]++
			}
			break
		}
	}

	fmt.Println(len(B))
	fmt.Println(string(B))
}

/*
- まずは全探索を検討しましょう
- MODは最後にとりましたか？
- ループを抜けた後も処理が必要じゃありませんか？
- 和・積・あまりを求められたらint64が必要ではありませんか？
- いきなりオーバーフローはしていませんか？
	- MOD取る系はint64必須ですよ？
*/

/*
ASCII code

ASCII   10進数  ASCII   10進数  ASCII   10進数
!       33      "       34      #       35
$       36      %       37      &       38
'       39      (       40      )       41
*       42      +       43      ,       44
-       45      .       46      /       47
0       48      1       49      2       50
3       51      4       52      5       53
6       54      7       55      8       56
9       57      :       58      ;       59
<       60      =       61      >       62
?       63      @       64      A       65
B       66      C       67      D       68
E       69      F       70      G       71
H       72      I       73      J       74
K       75      L       76      M       77
N       78      O       79      P       80
Q       81      R       82      S       83
T       84      U       85      V       86
W       87      X       88      Y       89
Z       90      [       91      \       92
]       93      ^       94      _       95
`       96      a       97      b       98
c       99      d       100     e       101
f       102     g       103     h       104
i       105     j       106     k       107
l       108     m       109     n       110
o       111     p       112     q       113
r       114     s       115     t       116
u       117     v       118     w       119
x       120     y       121     z       122
{       123     |       124     }       125
~       126             127
*/

/*******************************************************************/

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"strconv"
)

// -----------------------------------------------------------------------------

// IO helper functions

// Returns next token from input.  It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]byte, error)
var nextLine func() ([]byte, error)

// Holds a buffer for output.  It must be initialized by SetOutput().
// All IO fucntions (read*() and [e]print*()) should write to OutputWriter
// instead of this.
var OutputBuffer *bufio.Writer

// Holds an io.Writer.  It must be initialized by SetOutput()
var OutputWriter io.Writer

// Set IO functions for interactive input/output.
func SetInteractive(w io.Writer, r io.Reader) {
	SetUnbefferedInput(r)
	OutputBuffer = nil
	OutputWriter = w
}

// Setup OutputBuffer and OutputWriter.
func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

// Flushes OutputBuffer
func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

// Returns true if c is a white space
func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

func IsNewLine(c byte) bool {
	switch c {
	case '\n', '\r':
		return true
	}
	return false
}

// Setup nextToken with input buffer.
func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial

	restLn := func() ([]byte, error) {
		for i < len(b) && IsNewLine(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsNewLine(b[i]) {
			i++
		}
		return b[j:i], nil
	}

	initialLn := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextLine = restLn
		return restLn()
	}
	nextLine = initialLn
}

// Setup nextToken without input buffer.
func SetUnbefferedInput(r io.Reader) {
	buf := bufio.NewReader(r)
	var b []byte

	var i int
	nextToken = func() ([]byte, error) {
		var err error
		if i == len(b) {
			b, err = buf.ReadBytes('\n')
			if err != nil {
				return nil, err
			}
			i = 0
			j := len(b) - 1
			for 0 <= j && IsSpace(b[j]) {
				j--
			}
			b = b[0 : j+1]
		}
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
}

// -----------------------------------------------------------------------------

// IO functions

// Reads next token and return it as []byte
func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b
}

// Reads next token and return it as string
func reads() string {
	return string(readb())
}

// Read next line as []byte
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b
}

// Read next line as string
func readsln() string {
	return string(readbln())
}

// Reads next token and return it as int64
func readll() int64 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// Reads next token and return it as int
func readi() int {
	return int(readll())
}

// Reads next token and return it as float64
func readf() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// Write args to OutputWriter with the format f
func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(OutputWriter, f, args...)
}

// Write args to OutputWriter without format
func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(OutputWriter, args...)
}

// Write args to stderr with the format f
func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// Write args to stderr without format
func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// -----------------------------------------------------------------------------

// Simple math functions

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minll(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxll(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absll(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func gcdll(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcdll(b, a%b)
}

// set up IO functions
func init() {
	// for non-interactive
	SetInput(os.Stdin)
	SetOutput(os.Stdout)

	// Enable below when interactive.  Its ok to leave above intact.
	// SetInteractive(os.Stdout, os.Stdin)
}

func main() {
	defer Flush()

	n := readi()
	k := readi()
	b := readb()
	a := make([]int, n)
	for i := range a {
		a[i] = int(b[i] - '0')
	}

	x := a[:k]
	ok := true
	for r := k; r < n; r += k {
		y := a[r:min(n, r+k)]
		x2 := x[:len(y)]
		for j := range y {
			if x2[j] < y[j] {
				ok = false
			}
		}

	}

	if !ok {
		for i, j := 0, len(x)-1; i < j; i, j = i+1, j-1 {
			x[i], x[j] = x[j], x[i]
		}
		for i, c := 0, 1; c == 1; i++ {
			if i == k {
				x = append(x, 1)
				n++
				break
			}
			x[i]++
			if x[i] == 10 {
				x[i] = 0
			} else {
				break
			}
		}
		for i, j := 0, len(x)-1; i < j; i, j = i+1, j-1 {
			x[i], x[j] = x[j], x[i]
		}
	}

	var ans []int
	for len(ans) < n {
		ans = append(ans, x...)
	}
	ans = ans[:n]
	println(n)
	for i := range ans {
		printf("%d", ans[i])
	}
	println()
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"strconv"
)

// -----------------------------------------------------------------------------

// IO helper functions

// Returns next token from input.  It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]byte, error)
var nextLine func() ([]byte, error)

// Holds a buffer for output.  It must be initialized by SetOutput().
// All IO fucntions (read*() and [e]print*()) should write to OutputWriter
// instead of this.
var OutputBuffer *bufio.Writer

// Holds an io.Writer.  It must be initialized by SetOutput()
var OutputWriter io.Writer

// Set IO functions for interactive input/output.
func SetInteractive(w io.Writer, r io.Reader) {
	SetUnbefferedInput(r)
	OutputBuffer = nil
	OutputWriter = w
}

// Setup OutputBuffer and OutputWriter.
func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

// Flushes OutputBuffer
func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

// Returns true if c is a white space
func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

func IsNewLine(c byte) bool {
	switch c {
	case '\n', '\r':
		return true
	}
	return false
}

// Setup nextToken with input buffer.
func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial

	restLn := func() ([]byte, error) {
		for i < len(b) && IsNewLine(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsNewLine(b[i]) {
			i++
		}
		return b[j:i], nil
	}

	initialLn := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextLine = restLn
		return restLn()
	}
	nextLine = initialLn
}

// Setup nextToken without input buffer.
func SetUnbefferedInput(r io.Reader) {
	buf := bufio.NewReader(r)
	var b []byte

	var i int
	nextToken = func() ([]byte, error) {
		var err error
		if i == len(b) {
			b, err = buf.ReadBytes('\n')
			if err != nil {
				return nil, err
			}
			i = 0
			j := len(b) - 1
			for 0 <= j && IsSpace(b[j]) {
				j--
			}
			b = b[0 : j+1]
		}
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
}

// -----------------------------------------------------------------------------

// IO functions

// Reads next token and return it as []byte
func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b
}

// Reads next token and return it as string
func reads() string {
	return string(readb())
}

// Read next line as []byte
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b
}

// Read next line as string
func readsln() string {
	return string(readbln())
}

// Reads next token and return it as int64
func readll() int64 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// Reads next token and return it as int
func readi() int {
	return int(readll())
}

// Reads next token and return it as float64
func readf() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// Write args to OutputWriter with the format f
func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(OutputWriter, f, args...)
}

// Write args to OutputWriter without format
func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(OutputWriter, args...)
}

// Write args to stderr with the format f
func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// Write args to stderr without format
func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// -----------------------------------------------------------------------------

// Simple math functions

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minll(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxll(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absll(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func gcdll(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcdll(b, a%b)
}

// set up IO functions
func init() {
	// for non-interactive
	SetInput(os.Stdin)
	SetOutput(os.Stdout)

	// Enable below when interactive.  Its ok to leave above intact.
	// SetInteractive(os.Stdout, os.Stdin)
}

func main() {
	defer Flush()

	n := readi()
	k := readi()
	b := readb()
	a := make([]int, n)
	for i := range a {
		a[i] = int(b[i] - '0')
	}

	x := a[:k]
	ok := false
outer:
	for r := k; r < n; r += k {
		y := a[r:min(n, r+k)]
		x2 := x[:len(y)]
		for j := range y {
			if y[j] < x2[j] {
				ok = true
				break outer
			} else if x2[j] < y[j] {
				break outer
			}
		}

	}

	if !ok {
		for i, j := 0, len(x)-1; i < j; i, j = i+1, j-1 {
			x[i], x[j] = x[j], x[i]
		}
		for i := 0; i < len(x); i++ {
			x[i]++
			if x[i] == 10 {
				x[i] = 0
			} else {
				break
			}
		}
		for i, j := 0, len(x)-1; i < j; i, j = i+1, j-1 {
			x[i], x[j] = x[j], x[i]
		}
	}

	var ans []int
	for len(ans) < n {
		ans = append(ans, x...)
	}
	ans = ans[:n]
	println(n)
	for i := range ans {
		printf("%d", ans[i])
	}
	println()
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)

	var n, k int
	fmt.Fscan(in, &n)
	fmt.Fscanln(in, &k)

	x := make([]byte, n)
	for i := 0; i < n; i++ {
		b, _ := in.ReadByte()

		x[i] = b - '0'
	}

	for i := 0; i < n-k; i++ {
		if x[i+k] != x[i] {
			if x[i+k] < x[i] {
				x[i+k] = x[i]
				for j := i + k + 1; j < n; j++ {
					x[j] = x[j-k]
				}
			} else {
				steps := 1
				x[i+k-1]++
				for j := i + k - 1; j > 0; j-- {
					if x[j] >= 10 {
						x[j] -= 10
						x[j-1]++
						steps = i - j + 1
					}
				}

				for j := i + k; j < n; j++ {
					x[j] = x[j-k]
				}

				if x[0] >= 10 {
					n++
					x[0] -= 10
					tmp := make([]byte, n)
					copy(tmp[1:], x[:])
					tmp[0] = 1
					x = tmp
					steps = i
				}

				i -= steps
			}
		}
	}

	fmt.Fprintln(out, len(x))
	for i := 0; i < len(x); i++ {
		fmt.Fprint(out, x[i])
	}

	out.Flush()
}


package main

import (
	"fmt"
)

func readArr(n int) []int{
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}
	return arr
}

var (
	n, m int
	field [][]int
	maxLevel int
)

func read() {
	fmt.Scanf("%d %d\n", &n, &m)
	field = make([][]int, n)
	for i := n - 1; i >= 0; i-- {
		var str string
		fmt.Scan(&str)
		field[i] = make([]int, m+2)
		for j, char := range str {
			field[i][j] = int(char - '0')
			if field[i][j] == 1 && i > maxLevel {
				maxLevel = i
			}
		}
	}
}

func main() {
	read()
	cnt := func(i int) (l, r int) {
		lPos := m + 1
		rPos := 0
		for j := 0; j < m+2; j++ {
			if field[i][j] == 1 {
				if j > rPos {
					rPos = j
				}
				if j < lPos {
					lPos = j
				}
			}
		}
		l = rPos + 1
		r = m + 2 - lPos
		return
	}

	level := make([][2]int, maxLevel + 1)
	const left, right = 0, 1
	level[0][left] = 0
	level[0][right] = m + 1

	for i := 0; i < maxLevel; i++ {
		l, r := cnt(i)
		ltol := level[i][left] + 2*(l-1)
		ltor := level[i][left] + (m+2-1)
		rtor := level[i][right] + 2*(r-1)
		rtol := level[i][right] + (m+2-1)

		level[i+1][left] = min(ltol, rtol) + 1
		level[i+1][right] = min(ltor, rtor) + 1
	}

	l, r := cnt(maxLevel)
	fmt.Println(min(level[maxLevel][left] + l - 1, level[maxLevel][right] + r - 1))
}

func min(x, y int) int {
	if y < x {
		return y
	}
	return x
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	"strings"
)

// github.com/EndlessCheng/codeforces-go
func CF812B(_r io.Reader, _w io.Writer) {
	min := func(a, b int) int {
		if a < b {
			return a
		}
		return b
	}
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var n, m, ansL, ansR, posL, posR, maxFloor int
	Fscan(in, &n, &m)
	m++
	floors := make([]string, n)
	for i := range floors {
		Fscan(in, &floors[n-1-i])
	}
	for i, s := range floors {
		l := strings.IndexByte(s, '1')
		if l == -1 {
			continue
		}
		maxFloor = i
		r := strings.LastIndexByte(s, '1')
		if ansL == 0 {
			ansL, ansR = r, r
			posL, posR = r, r
		} else {
			ansL, ansR = min(ansL+m-posL, ansR+m-posR)+m-l, min(ansL+posL, ansR+posR)+r
			posL, posR = l, r
		}
	}
	Fprint(out, min(ansL, ansR)+maxFloor)
}

func main() {
	CF812B(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
    "strings"
)

const (
    INF = 123454321
)

func Init() {
}

func Solve(io *FastIO) {
    N := io.NextInt()
    M := io.NextInt()

    F := make([]Floor, 0, N)
    for i := 0; i < N; i++ {
        S := io.NextLine()

        if len(F) == 0 && !strings.Contains(S, "1") {
            continue
        }
        F = append(F, FloorFromString(S))
    }

    H := len(F)
    if H == 0 {
        io.Println(0)
        return
    }

    bestL := 0
    bestR := INF
    for i := H - 1; i > 0; i-- {
        bestL, bestR = 1 + Min(bestL + (F[i].R << 1), bestR + M + 1),
                       1 + Min(bestR + ((M + 1 - F[i].L) << 1), bestL + M + 1)
    }
    io.Println(Min(bestL + F[0].R, bestR + M + 1 - F[0].L))
}

type Floor struct {
    L int
    R int
}

func FloorFromString(S string) Floor {
    left := len(S) - 1
    right := 0
    for i := 1; i < len(S) - 1; i++ {
        if S[i] == '1' {
            left = Min(left, i)
            right = Max(right, i)
        }
    }
    return Floor{
        L: left,
        R: right,
    }
}

func Min(args ...int) int {
	min := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] < min {
			min = args[i]
		}
	}
	return min
}

func Max(args ...int) int {
	max := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] > max {
			max = args[i]
		}
	}
	return max
}

type FastIO struct {
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}

func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = (res * 10) + int(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = (res * 10) + int64(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}

func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextInt()
	}
	return arr
}

func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}

func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextLong()
	}
	return arr
}

func (io *FastIO) NextString() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}

func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}

func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}

func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}

func IsLineBreakChar(c byte) bool {
	switch c {
		case 0, '\n', '\r':
			return true
		default:
			return false
	}
}

func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Init()
	Solve(&io)
	io.FlushOutput()
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	n := readInt()
	m := readInt()
	a := make([]string, n)
	cnt := 0
	for i := 0; i < n; i++ {
		a[i] = readString()
		for _, v := range a[i] {
			if v == '1' {
				cnt++
			}
		}
	}
	if cnt > 0 {
		fmt.Println(dfs(n, m, a, n-1, true, cnt))
	} else {
		fmt.Println(0)
	}
}

func dfs(n, m int, a []string, y int, left bool, cnt int) int {
	if y < 0 {
		return 0
	}
	if left {
		need := 0
		localFound := 0
		for i := 0; i < m+2; i++ {
			if a[y][i] == '1' {
				need = i
				localFound++
			}
		}
		if localFound == 0 {
			return 1 + dfs(n, m, a, y-1, left, cnt)
		}
		if localFound == cnt {
			return need
		}
		return min(
			need+need+1+dfs(n, m, a, y-1, true, cnt-localFound),
			1+m+2-1+dfs(n, m, a, y-1, false, cnt-localFound))
	} else {
		need := 0
		localFound := 0
		steps := 0
		for i := m - 1 + 2; i >= 0; i-- {
			if a[y][i] == '1' {
				need = steps
				localFound++
			}
			steps++
		}
		if localFound == 0 {
			return 1 + dfs(n, m, a, y-1, left, cnt)
		}
		if localFound == cnt {
			return need
		}
		return min(
			need+need+1+dfs(n, m, a, y-1, false, cnt-localFound),
			1+m+1+dfs(n, m, a, y-1, true, cnt-localFound))
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

package main

import (
	"fmt"
)

func readArr(n int) []int{
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}
	return arr
}

var (
	n, m int
	field [][]int
)

func read() {
	fmt.Scanf("%d %d\n", &n, &m)
	field = make([][]int, n)
	for i := n - 1; i >= 0; i-- {
		var str string
		fmt.Scan(&str)
		field[i] = make([]int, m+2)
		for j, char := range str {
			field[i][j] = int(char - '0')
		}
	}
}

func main() {
	read()
	level := make([][2]int, n)
	const left, right = 0, 1
	level[0][left] = 0
	level[0][right] = m + 1
	cnt := func(i int) (l, r int) {
		lPos := m + 1
		rPos := 0
		for j := 0; j < m+2; j++ {
			if field[i][j] == 1 {
				if j > rPos {
					rPos = j
				}
				if j < lPos {
					lPos = j
				}
			}
		}
		l = rPos + 1
		r = m + 2 - lPos
		return
	}

	for i := 0; i < n - 1; i++ {
		l, r := cnt(i)
		ltol := level[i][left] + 2*(l-1)
		ltor := level[i][left] + (m+2-1)
		rtor := level[i][right] + 2*(r-1)
		rtol := level[i][right] + (m+2-1)

		level[i+1][left] = min(ltol, rtol) + 1
		level[i+1][right] = min(ltor, rtor) + 1
	}

	l, r := cnt(n - 1)
	fmt.Println(min(level[n-1][left] + l - 1, level[n-1][right]) + r - 1)
}

func min(x, y int) int {
	if y < x {
		return y
	}
	return x
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	"strings"
)

// github.com/EndlessCheng/codeforces-go
func CF812B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var n, m, ans, pos, maxFloor int
	Fscan(in, &n, &m)
	m++
	floors := make([]string, n)
	for i := range floors {
		Fscan(in, &floors[n-1-i])
	}
	for i, s := range floors {
		l := strings.IndexByte(s, '1')
		if l == -1 {
			continue
		}
		maxFloor = i
		r := strings.LastIndexByte(s, '1')
		if ans == 0 {
			ans = r
			pos = r
		} else {
			if ansL, ansR := ans+pos+r, ans+m-pos+m-l; ansL < ansR {
				ans = ansL
				pos = r
			} else {
				ans = ansR
				pos = l
			}
		}
	}
	Fprint(out, ans+maxFloor)
}

func main() {
	CF812B(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	"strings"
)

// github.com/EndlessCheng/codeforces-go
func CF812B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var n, m, ans, pos int
	Fscan(in, &n, &m)
	m++
	floors := make([]string, n)
	for i := range floors {
		Fscan(in, &floors[n-1-i])
	}
	for _, s := range floors {
		l := strings.IndexByte(s, '1')
		if l == -1 {
			continue
		}
		r := strings.LastIndexByte(s, '1')
		if ans == 0 {
			ans = r
			pos = r
		} else {
			if ansL, ansR := ans+pos+1+r, ans+m-pos+1+m-l; ansL < ansR {
				ans = ansL
				pos = r
			} else {
				ans = ansR
				pos = l
			}
		}
	}
	Fprint(out, ans)
}

func main() {
	CF812B(os.Stdin, os.Stdout)
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func getLine() string {
	s, _ := reader.ReadString('\n')
	if strings.HasSuffix(s, "\r\n") {
		s = s[:len(s)-2]
	} else if strings.HasSuffix(s, "\n") {
		s = s[:len(s)-1]
	}
	return s
}
func getLine2Int() (n int) {
	scanf("%d\n", &n)
	return
}
func getLine2Int2() (a, b int) {
	scanf("%d %d\n", &a, &b)
	return
}
func getLine2Ints(n int) []int {
	ans := make([]int, n)
	for i := 0; i < n; i++ {
		scanf("%d ", &ans[i])
	}
	scanf("%d\n", &ans[n-1])
	return ans
}

var debug = true

func see(a interface{}) {
	if debug {
		printf("DEBUG:%v\n", a)
	}
}

var mod = int64(1000000007)

func sqr(i int64) int64 {
	return i * i % mod
}
func mypow2(a, n int64) int64 {
	if n == 0 {
		return 1
	}
	if n%2 == 1 {
		return sqr(mypow2(a, n/2)) * a % mod
	}
	return sqr(mypow2(a, n/2))
}

func mypow(i, n int) int64 {
	return mypow2(int64(i), int64(n))
}

func main() {
	defer writer.Flush()

	n := getLine2Int()
	s := getLine()
	var a, c, g, t int
	for i := 0; i < n; i++ {
		switch s[i] {
		case 'A':
			a++
		case 'C':
			c++
		case 'G':
			g++
		case 'T':
			t++
		}
	}
	m := a
	if c > m {
		m = c
	}
	if g > m {
		m = g
	}
	if t > m {
		m = t
	}
	i := 0
	if a == m {
		i++
	}
	if g == m {
		i++
	}
	if c == m {
		i++
	}
	if t == m {
		i++
	}
	printf("%d\n", mypow(i, n))
}

package main

import (
	"fmt"
)

// 10^9 + 7
const MD = 1000000007

func main() {
	var N int
	var S string
	fmt.Scan(&N, &S)
	z := make(map[rune]int64)
	for _, r := range S {
		z[r]++
	}
	var x, y, ans int64
	for _, v := range z {
		if x < v {
			x = v
		}
	}
	for _, v := range z {
		if v == x {
			y++
		}
	}
	ans = 1
	for i := 0; i < N; i++ {
		ans = ans * y % MD
	}
	fmt.Println(ans)
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

const MOD = int64(1e9 + 7)

type pis struct {
	x string
	y int
}

func main() {
	io := NewFastIO(os.Stdin, os.Stdout)
	defer io.Flush()

	n := io.NextInt()
	s := io.Next()

	MP := make(map[int]int)

	for i := 0; i < n; i++ {
		MP[int(s[i])]++
	}

	mx := 0
	for _, v := range MP {
		if v > mx {
			mx = v
		}
	}
	c := 0
	for _, v := range MP {
		if v == mx {
			c++
		}
	}
	io.Println(power(int64(c), int64(n)))
}

func power(a, b int64) int64 {
	r := int64(1)
	for b > 0 {
		if b&1 == 1 {
			r *= a
			r %= MOD
		}
		a = (int64(a) * a) % MOD
		b = b / 2
	}
	return r
}

type FastIO struct {
	*bufio.Reader
	*bufio.Writer
	c [1]byte
}

func NewFastIO(r io.Reader, w io.Writer) *FastIO {
	return &FastIO{Reader: bufio.NewReader(r), Writer: bufio.NewWriter(w)}
}

func (f *FastIO) readC() byte {
	f.Read(f.c[:])
	return f.c[0]
}

func (f *FastIO) NextInt() int {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	neg := false
	if c == '-' {
		neg = true
		c = f.readC()
	}
	n := 0
	for ; '0' <= c && c <= '9'; c = f.readC() {
		n = n*10 + int(c) - '0'
	}
	if neg {
		return -n
	}
	return n
}

func (f *FastIO) NextInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = f.NextInt()
	}
	return a
}

func (f *FastIO) Next() string {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	var s []byte
	for ; c > ' '; c = f.readC() {
		s = append(s, f.c[0])
	}
	return string(s)
}

func (f *FastIO) Println(a ...interface{}) {
	fmt.Fprintln(f.Writer, a...)
}

func (f *FastIO) Print(a ...interface{}) {
	fmt.Fprint(f.Writer, a...)
}

func (f *FastIO) PrintInts(a ...int) {
	if len(a) > 0 {
		f.Print(a[0])
		for _, x := range a[1:] {
			f.Print(" ", x)
		}
	}
}

func (f *FastIO) PrintlnInts(a ...int) {
	f.PrintInts(a...)
	f.Println()
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	"sort"
)

func Sol520C(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	var s string
	Fscan(in, &n, &s)

	// 找规律，观察发现对于 AAG 这样自由一个字母最多的情况，答案只有一种就是 AAA
	// 对于 AAGGT 这样有 m 种字母一样最多的情况，由于滚动循环消除了不同排列的区别，每个位上既可以是 A 也可以是 G，这样答案是 pow(m,n)
	cnts := make([]int, 26)
	for _, c := range s {
		cnts[c-'A']++
	}
	sort.Ints(cnts)
	m := int64(0)
	for _, c := range cnts {
		if c == cnts[25] {
			m++
		}
	}
	const mod = int64(1e9 + 7)
	ans := int64(1)
	for ; n > 0; n >>= 1 {
		if n&1 == 1 {
			ans = ans * m % mod
		}
		m = m * m % mod
	}
	Fprintln(out, ans)
}

func main() {
	Sol520C(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

const MOD = int(1e9 + 7)

type pis struct {
	x string
	y int
}

func main() {
	io := NewFastIO(os.Stdin, os.Stdout)
	defer io.Flush()

	n := io.NextInt()
	s := io.Next()

	MP := make(map[int]int)

	for i := 0; i < n; i++ {
		MP[int(s[i])]++
	}

	mx := 0
	for _, v := range MP {
		if v > mx {
			mx = v
		}
	}
	c := 0
	for _, v := range MP {
		if v == mx {
			c++
		}
	}
	r := int64(1)
	for i := 0; i < n; i++ {
		r = r * int64(c)
		r = r % int64(MOD)
	}
	io.Println(r)
}

type FastIO struct {
	*bufio.Reader
	*bufio.Writer
	c [1]byte
}

func NewFastIO(r io.Reader, w io.Writer) *FastIO {
	return &FastIO{Reader: bufio.NewReader(r), Writer: bufio.NewWriter(w)}
}

func (f *FastIO) readC() byte {
	f.Read(f.c[:])
	return f.c[0]
}

func (f *FastIO) NextInt() int {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	neg := false
	if c == '-' {
		neg = true
		c = f.readC()
	}
	n := 0
	for ; '0' <= c && c <= '9'; c = f.readC() {
		n = n*10 + int(c) - '0'
	}
	if neg {
		return -n
	}
	return n
}

func (f *FastIO) NextInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = f.NextInt()
	}
	return a
}

func (f *FastIO) Next() string {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	var s []byte
	for ; c > ' '; c = f.readC() {
		s = append(s, f.c[0])
	}
	return string(s)
}

func (f *FastIO) Println(a ...interface{}) {
	fmt.Fprintln(f.Writer, a...)
}

func (f *FastIO) Print(a ...interface{}) {
	fmt.Fprint(f.Writer, a...)
}

func (f *FastIO) PrintInts(a ...int) {
	if len(a) > 0 {
		f.Print(a[0])
		for _, x := range a[1:] {
			f.Print(" ", x)
		}
	}
}

func (f *FastIO) PrintlnInts(a ...int) {
	f.PrintInts(a...)
	f.Println()
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func getLine() string {
	s, _ := reader.ReadString('\n')
	if strings.HasSuffix(s, "\r\n") {
		s = s[:len(s)-2]
	} else if strings.HasSuffix(s, "\n") {
		s = s[:len(s)-1]
	}
	return s
}
func getLine2Int() (n int) {
	scanf("%d\n", &n)
	return
}
func getLine2Int2() (a, b int) {
	scanf("%d %d\n", &a, &b)
	return
}
func getLine2Ints(n int) []int {
	ans := make([]int, n)
	for i := 0; i < n; i++ {
		scanf("%d ", &ans[i])
	}
	scanf("%d\n", &ans[n-1])
	return ans
}

var debug = false

func see(a interface{}) {
	if debug {
		printf("DEBUG:%v\n", a)
	}
}

var mod = int64(1000000007)

func sqr(i int64) int64 {
	return i * i & mod
}
func mypow2(a, n int64) int64 {
	if n == 0 {
		return 1
	}
	if n%2 == 1 {
		return sqr(mypow2(a, n/2)) * a % mod
	}
	return sqr(mypow2(a, n/2)) % mod
}

func mypow(i, n int) int64 {
	return mypow2(int64(i), int64(n))
}

func main() {
	defer writer.Flush()

	n := getLine2Int()
	s := getLine()
	var a, c, g, t int
	for i := 0; i < n; i++ {
		switch s[i] {
		case 'A':
			a++
		case 'C':
			c++
		case 'G':
			g++
		case 'T':
			t++
		}
	}
	m := a
	if c > m {
		m = c
	}
	if g > m {
		m = g
	}
	if t > m {
		m = t
	}
	i := 0
	if a == m {
		i++
	}
	if g == m {
		i++
	}
	if c == m {
		i++
	}
	if t == m {
		i++
	}
	printf("%d\n", mypow(i, n))
}

package main

import (
	"fmt"
)

// 10^9 + 7
const MD = 1000000007

func main() {
	var N int
	var S string
	fmt.Scan(&N, &S)
	z := make(map[rune]int)
	for _, r := range S {
		z[r]++
	}
	x := 0
	for _, v := range z {
		if v > x {
			x = v
		}
	}
	y := 0
	for _, v := range z {
		if x == v {
			y++
		}
	}
	ans := 1
	for i := 0; i < N; i++ {
		ans = ans * y % MD
	}
	fmt.Println(ans)
}