import java.util.*;
import java.lang.*;
import java.io.*;

// The main method must be in a class named "Main".
class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String str1=sc.next();
        int n=str1.length();
        Set<Character> ch=new HashSet<>();
        int max_size=0;
        int left=0;
        for(int i=0;i<n;i++){
            while(ch.contains(str1.charAt(i))){
                ch.remove(str1.charAt(++left));
            }
            ch.add(str1.charAt(i));
            max_size=Math.max(max_size,i-left+1);
        }
        System.out.println(max_size);
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: