private static int check_answer(List<String> s) {
    int closest_dis = Integer.MAX_VALUE;
    for (int i = 0; i < s.size(); ++i) {
      for (int j = i + 1; j < s.size(); ++j) {
        if (s.get(i).equals(s.get(j))) {
          closest_dis = Math.min(closest_dis, j - i);
        }
      }
    }
    return closest_dis;
  }