#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char s[256];
int maxPalNum = 0;
int champion = 0;
int currentSentence = 1;
int palCount = 0;
while (cin >> s)
{
if (s[0] == '-' && strlen(s) == 1)
continue;
bool endOfSentence = false;
if (s[strlen(s)-1] == '.' || s[strlen(s)-1] == '!' || s[strlen(s)-1] == '?')
endOfSentence = true;
for (int i = strlen(s) - 1; i >= 0; i--)
{
if (!(s[i] >= 'a' && s[i] <= 'z' || s[i] >= 'A' && s[i] <= 'Z' || s[i] >= '1' && s[i] <= '9' || s[i] == '-'))
s[i] = '\0';
else
break;
}
bool pal = true;
for (int i = 0; i < strlen(s) / 2; i++)
{
if (s[i] >= 'A' && s[i] <= 'Z')
s[i] += 32;
if (s[strlen(s)-i-1] >= 'A' && s[strlen(s)-i-1] <= 'Z')
s[strlen(s)-i-1] += 32;
if (s[i] != s[strlen(s)-i-1])
{
pal = false;
break;
}
}
if (pal)
palCount ++;
if (endOfSentence)
{
if (palCount > maxPalNum)
{
maxPalNum = palCount;
champion = currentSentence;
}
currentSentence++;
palCount = 0;
}
}
cout << champion;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0cmluZz4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkgCnsKCWNoYXIgc1syNTZdOwoJaW50IG1heFBhbE51bSA9IDA7CglpbnQgY2hhbXBpb24gPSAwOwoJaW50IGN1cnJlbnRTZW50ZW5jZSA9IDE7IAoJaW50IHBhbENvdW50ID0gMDsKCXdoaWxlIChjaW4gPj4gcykKCXsKCQlpZiAoc1swXSA9PSAnLScgJiYgc3RybGVuKHMpID09IDEpCgkJCWNvbnRpbnVlOwoJCWJvb2wgZW5kT2ZTZW50ZW5jZSA9IGZhbHNlOwoJCWlmIChzW3N0cmxlbihzKS0xXSA9PSAnLicgfHwgc1tzdHJsZW4ocyktMV0gPT0gJyEnIHx8IHNbc3RybGVuKHMpLTFdID09ICc/JykKCQkJZW5k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