#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define faster() cin.tie(0); ios_base::sync_with_stdio(false); cout.tie(0);
string xuly(string s, int k){
    stack<pair<char,int>> st;
    for(int i = 0 ; i < s.size() ; i++){
        if(!st.empty() && s[i] == st.top().first && st.top().second == k - 1){
            st.pop();
        }
        else{
            if(st.empty() || s[i] != st.top().first) st.push({s[i],1});
            else st.top().second++;
        }
    }
    string res = "";
    while(!st.empty()){
        auto it = st.top();st.pop();
        for(int i = 0 ; i < it.second ; i++){
            res += it.first;
        }
    }
    reverse(res.begin(),res.end());
    return res;
}
int main(){
    faster()
    string s;
    cin >> s;
    int k ;cin >> k;
    if(xuly(s,k) == "") cout << "empty\n";
    else{
    cout << xuly(s,k);
    }
}

