While Mike was walking in the subway, all the stuff in his back-bag dropped on the ground. There were several fax messages among them. He concatenated these strings in some order and now he has string s.

 [Image] 

He is not sure if this is his own back-bag or someone else's. He remembered that there were exactly k messages in his own bag, each was a palindrome string and all those strings had the same length.

He asked you to help him and tell him if he has worn his own back-bag. Check if the given string s is a concatenation of k palindromes of the same length.


-----Input-----

The first line of input contains string s containing lowercase English letters (1 ≤ |s| ≤ 1000).

The second line contains integer k (1 ≤ k ≤ 1000).


-----Output-----

Print "YES"(without quotes) if he has worn his own back-bag or "NO"(without quotes) otherwise.


-----Examples-----
Input
saba
2

Output
NO

Input
saddastavvat
2

Output
YES



-----Note-----

Palindrome is a string reading the same forward and backward.

In the second sample, the faxes in his back-bag can be "saddas" and "tavvat".

Difficulty: interview

Starter code:

Solutions:
def check(pali):
    for i in range(len(pali) // 2):
        if pali[i] != pali[-i - 1]:
            return False

    return True


def __starting_point():
    s = input()
    k = int(input())

    if len(s) % k != 0:
        print('NO')
        return

    step = len(s) // k
    for i in range(k):
        if not check(s[i * step: (i + 1) * step]):
            print('NO')
            return

    print('YES')
__starting_point()

import sys;
import math
import time
import random
import functools

def pal(x):
    for i in range(len(x)//2):
        if x[i] != x[len(x) - i - 1]:
            return False
    return True

s = input()
k = int(input())

l = 0
if len(s)%k == 0:
    l = len(s)//k
else:
    print("NO")
    return

for i in range(k):
    q = ""
    for j in range(l*i, l*i+l):
        q+=s[j]
    if not pal(q):
        print("NO")
        return

print("YES")

def sol():
    s = input()
    k = int(input())

    if len(s) % k:
        return "NO"
    else:
        l = len(s) // k
        for i in range(k):
            st = s[i*l:(i+1)*l]
            if st != st[::-1]:
                break
        else:
            return "YES"
        return "NO"

print(sol())


s = input()
k = int(input())

def solve(s, k):
    if len(s) % k > 0:
        print("NO")
        return
    l = len(s) // k
    for i in range(k):
        for j in range(l // 2):
            if s[i * l + j] != s[i * l + l - j - 1]:
                print("NO")
                return
    print("YES")

solve(s, k)

s = input()
n = int(input())
if len(s)%n == 0:
    for i in range(n):
        t = s[len(s)//n*i:len(s)//n*(i+1)]
        if t != t[::-1]:
            print("NO")
            break
    else:
        print("YES")
else:
    print("NO")



import math
import sys

s=input()
k=int(input())
l=len(s)
if l%k==0:
    d=round(l/k)
    fail=0
    for i in range(0,k):
        for j in range(0,d):
            if s[d*i+j] != s[d*i+d-j-1]:
                fail=1
    if fail==1:
        print("NO")
    else:
        print("YES")
else:
    print("NO")


s = input()
n = int(input())
one = len(s) // n
if len(s) % n != 0:
    print('NO')
    return
for i in range(0, len(s), one):
    our = s[i:i + one]
    if our != our[::-1]:
        print('NO')
        return
print('YES')

import math
def main():
    s = input()
    k = int(input())
    ns = len(s)
    if ns % k != 0:
        print('NO')
        return
    k = int(ns/k)
    while len(s)>0:
        crt = s[:k]
        crt1 = crt[::-1]
        s = s[k:]
        if crt != crt1:
            print('NO')
            return
    print('YES')
        
def __starting_point():
    main()

__starting_point()

import sys
s = input()
k = int(input())
def isPalind(s) :
    for i in range(len(s)//2) :
        if s[i]!=s[len(s)-1-i] :
            return False
    return True
if len(s)%k!=0 :
    print('NO')
else :
    l = len(s)//k
    i=0
    while i<len(s) :
        if not isPalind(s[i:i+l]) :
            print('NO')
            return
        i+=l
    print('YES')
    


def f(s, k):
    for j in range(k - k // 2):
        if s[j] != s[-(j + 1)]:
            return False
    else:
        return True
s = input()
k = int(input())
if len(s) % k != 0:
    print('NO')
else:
    k = len(s) // k
    for i in range(0, len(s), k):
        if not f(s[i:i + k], k):
            print('NO')
            break
    else:
        print('YES')

def pal(s):
    return s == s[::-1]
s, k = input(), int(input())
if len(s) % k != 0:
    print('NO')
else:
    n = len(s) // k
    print('YES' if all(pal(s[i * n:(i + 1) * n]) for i in range(k)) else 'NO')

def f(str):
    for i in range(len(str) // 2):
        if str[i] != str[len(str) - 1 - i]:
            return False
    return True


s = input()
k = int(input())
if len(s) % k != 0:
    print('NO')
else:
    ans = True
    count = len(s) // k
    for i in range(k):
        ans = ans and f(s[i * count:(i + 1) * count])
    print('YES' if ans else 'NO')

__author__ = 'Snopi'

s = input()
k = int(input())
if len(s) % k != 0:
    print("NO")
    return

o = len(s) // k

for j in range(k):
    lal = s[j*o:(j + 1)*o]
    if lal != "".join(reversed(lal)):
        print("NO")
        return

print("YES")

s = input()
n = int(input())
#a = [int(c) for c in input().split()]

wordlength = len(s)//n
if wordlength*n != len(s):
    print("NO")
else:
    current = wordlength
    word = 0
    yes = True
    for i in range(n):
        if not yes:
            break
        for j in range(wordlength):

            if s[i*wordlength + j] != s[(i+1)*wordlength - j - 1]:
                yes = False
                break

    if yes:
        print("YES")
    else:
        print("NO")

s = input()
k = int(input())

length = len(s)
tokenLength = length / k

if length % k != 0:
    print("NO")
    return

for i in range(k):
    toCheck = s[i * int(tokenLength) : i * int(tokenLength) + int(tokenLength)]
    if toCheck != toCheck[::-1]:
        print("NO")
        return

print("YES")


#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import time

def polytest(str):
    flag = True
    for i in range(divmod(len(str),2)[0]):
        if str[i] != str[-i-1]:
            flag = False
            break
    return flag

str = input()
k   = int(input())

start = time.time()
dm = divmod(len(str), k)

if dm[1] != 0:
    ans = "NO"
else:
    for i in range(k):
        ans = "YES"
        if polytest(str[i*dm[0]: (i+1)*dm[0]]) == False:
            ans="NO"
            break

print(ans)
finish = time.time()
#print (finish - start), "sec"


s = input()
b = [int(s) for s in input().split()][0]
a = list()
if len(s)%b:
    print("NO")
else:
    for i in range(0, len(s)-len(s)//b+1, len(s)//b):
        a.append(s[i:i+len(s)//b])
    for i in a:
        if not i == i[::-1]:
            print("NO")
            break
    else:
        print("YES")



from sys import*
def pol(s):
    n = len(s)
    for i in range(n // 2 + 1):
        if s[i] != s[-1 - i]:
            return False
    return True
s = input()
k = int(input())
if len(s) % k == 0:
    n = len(s) // k
    for i in range(k):
        #print(s[0 : n])
        if not pol(s[0 : n]):
            print("NO")
            return
        s = s[n:]
    print("YES")
            
else:
    print("NO")


s, k = input(), int(input())
if len(s) % k:
    print("NO")
    return

l = int(len(s) / k)
for p in (s[i*l:(i+1)*l] for i in range(k)):
    if p != p[::-1]:
        print("NO")
        return
print("YES")


fax = input()
i = int(input())

if len(fax) % i != 0:
    print('NO')
else:
    for m in range(i):
        temp = fax[m * (len(fax) // i): (m + 1) * (len(fax) // i)]
        if temp != temp[::-1]:
            print('NO')
            break
    else:
        print('YES')


from fileinput import *

for line in input():
    if lineno() == 1:
        s = line.strip()
    if lineno() == 2:
        n = int(line.strip())

sl = len(s)
unit_length = sl // n

newlist = []

for i in range(n):
    newlist.append(s[i*unit_length:i*unit_length+unit_length])


def is_p(word):
    return word == word[::-1]

res = True
for word in newlist:
    if is_p(word):
        pass
    else:
        res = False
        break

if res and sl % n == 0:
    print('YES')
else:
    print('NO')


m=str(input())
z=int(input())

def pol(s):
    for i in range(int(len(s)/2)):
        if not(s[i]==s[len(s)-1-i]):
            return False
            break;
    return True

#pol(m)
l=len(m)

l1=int(l/z)
#print (l1)
start=0
end=l1
if ((len(m)<z) or (not(l%z)==0)):
    print("NO")
    return
for j in range(z):
    u=m[start:end]
    start+=l1
    end+=l1
    if (not(pol(u))):
        print("NO")
        return
print("YES")


s = input()
k = int(input())
leng = len(s) // k
ans = 'YES'
if len(s) % k != 0:
    ans = 'NO'
for i in range(k):
    a = s[i * leng : (i + 1) * leng]
    if a != a[::-1]:
        ans = 'NO'
print(ans)

def chunks(l, n):
  for i in range(0, len(l), n):
    yield l[i:i+n]

def palindrome(s):
  for i in range(len(s)):
    if s[i] != s[-(i+1)]:
      return False
  else:
    return True

import sys
data, num = sys.stdin.readlines()
data = data.strip()
num = int(num.strip())


if num > len(data):
  print("NO")
elif num == len(data):
  print("YES")
else:
  if len(data) % num == 0:
    for c in chunks(data, int(len(data)/num)):
      if not palindrome(c):
        print("NO")
        return
    else:
      print("YES")
  else:
    print("NO")