#include #include #include using namespace std; int part1(string signal, int target) { constexpr int amt = 'z' - 'a' + 1; int last[amt]; int last_rep = -1; fill(begin(last), end(last), -10); for (int i = 0; i < signal.length(); i++) { int c = signal[i] - 'a'; if (c >= amt) throw "bad input"; last_rep = max(last_rep, last[c]); if (i - last_rep >= target) { return i + 1; } last[c] = i; } return -1; } int main() { for (string line; getline(cin, line); ) { cout << part1(line, 4) << endl; cout << part1(line, 14) << endl; } }