#include <iostream>
#include <string>
using namespace std;
int main() {
string s;
char a;
cin>>a;
float b;
s=a;
cin>>b;
cout<<((2+3*(b-1))*b)/2<<endl;
for(int i;i<b;i++){
for(int j=1;j<b-i;j++)
cout<<" ";
cout<<s;
s=a+s+a;
cout<<endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkgewoJc3RyaW5nIHM7CgljaGFyIGE7CgljaW4+PmE7CglmbG9hdCBiOwoJcz1hOwoJY2luPj5iOwoJY291dDw8KCgyKzMqKGItMSkpKmIpLzI8PGVuZGw7Cglmb3IoaW50IGk7aTxiO2krKyl7CgkJZm9yKGludCBqPTE7ajxiLWk7aisrKQoJCSAgICAgICBjb3V0PDwiICI7CgkJY291dDw8czsKCQlzPWErcythOwoJCWNvdXQ8PGVuZGw7Cgl9CglyZXR1cm4gMDsKfQ==