#include <stdio.h>  
  
int main() {  
    char phone[11];  
    int i, j;  
    j = scanf("%s %d", phone, &i);  
      
    while (j != EOF) {  
        if (i < -1 || i > 9) {  
            printf("ERROR\n");  
        } else if (i == -1) {  
            printf("%s\n", phone);  
        } else {  
            printf("%c\n", phone[i]);}  
    j = scanf("%d", &i);  
    }  
  
    return 0;  
} 