function issue(input: string) { const text: string[] = input.split('\r\n'); const a: number = ( text[0].match( new RegExp( text[1], "g" ) ) || [] ).length ; if (a >= 0) { console.log(a); } else { console.log(-1); } } issue(require('fs').readFileSync('/dev/stdin', 'utf8'));