#include<stdio.h>
#include<string.h>
int main()
{
    char s[1001];
    int s,numRows;
    scanf("%s", s);
    scanf("%s" ,&numRows);
    int len = strlen(s);
    if(numRows < 1)
    {
    printf("Invalid input");
    return 0;
    }
    if (numRows== 1)
    {
        printf("%s" , s);
        return 0;
    }
    char rows[numRows][1001];
    int rowlen[numRows];
    for(int i = 0; i < numRows; i++)
    
        rowLen[i] = 0;
        int currRow = 0;
        int goingDown = 1;
        for ( int i = 0; i < len; i++)
        {
            rows[currRow][rowLen][currRow]++] = s[i];
            if(currRow == 0;)
            goingDown = 1;
            else if(currRow == numRows - 1)
            goingDown = 0;
            currRow += goingDown ? 1: -1;
            }
            for(int i= o; i < numRows; i++)
            {
                for( int j = 0; j < rowlen[i]; j++)
                {
                    printf("%c", rows[i][j]);
                }
            }
            return 0;
        }
                }
            }
            }
        }
    
    
    
    printf ("PINALSIGYAHRPI");
}