int (@NotNull CharSequence text) { int count = 0; for (int i = 0; i < text.length(); i++) { char c = text.charAt(i); if (c == '\n') { count++; } else if (c == '\r') { if (i + 1 < text.length() && text.charAt(i + 1) == '\n') { //noinspection AssignmentToForLoopParameter i++; } count++; } } return count; }