/*****Author: Satyajeet Singh, Delhi Technological University************************************/
    import java.io.*;
    import java.util.*;
    import java.text.*;
    import java.lang.*;
    import java.math.*;
public class Main{
/*********************************************Constants******************************************/
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static long mod=(long)1e9+7;
    static long mod1=998244353;
    static boolean sieve[];
    static ArrayList<Integer> primes;
    static long factorial[],invFactorial[];
    static ArrayList<Integer> graph[];
    static int pptr=0;
    static String st[];
/****************************************Solutions Begins***************************************/
    public static void main(String args[]) throws Exception{
        nl();
        String str=ps();
        int n=str.length();
        long dp1[]=new long[26];
        long dp2[]=new long[26];
        long ans=0;
        for(int i=0;i<n;i++){
            int c=str.charAt(i)-'a';
            dp1[c]++;
            ans=Math.max(ans,dp1[c]);
        }
        for(int i=0;i<n-1;i++){
            int c=str.charAt(i)-'a';
            dp2[c]++;
            dp1[c]--;
            for(int j=0;j<26;j++){
                ans=Math.max(ans,dp1[j]*dp2[c]);
            }
        }
        out.println(ans);
/****************************************Solutions Ends**************************************************/
        out.flush();
        out.close();
    }
/****************************************Template Begins************************************************/
    static void nl() throws Exception{
        pptr=0;
        st=br.readLine().split(" ");
    }
    static void nls() throws Exception{
        pptr=0;
        st=br.readLine().split("");
    }
    static int pi(){
        return Integer.parseInt(st[pptr++]);
    }
    static long pl(){
        return Long.parseLong(st[pptr++]);
    }
    static double pd(){
        return Double.parseDouble(st[pptr++]);
    }
    static String ps(){
        return st[pptr++];
    }
/***************************************Precision Printing**********************************************/
    static void printPrecision(double d){
        DecimalFormat ft = new DecimalFormat("0.000000000000");
        out.print(ft.format(d));
    }
/**************************************Bit Manipulation**************************************************/
    static void printMask(long mask){
        System.out.println(Long.toBinaryString(mask));
    }
    static int countBit(long mask){
        int ans=0;
        while(mask!=0){
            mask&=(mask-1);
            ans++;
        }
        return ans;
    }
/******************************************Graph*********************************************************/
    static void Makegraph(int n){
        graph=new ArrayList[n];
        for(int i=0;i<n;i++){
            graph[i]=new ArrayList<>();
        }
    }
    static void addEdge(int a,int b){
        graph[a].add(b);
    }
    // static void addEdge(int a,int b,int c){
    //     graph[a].add(new Pair(b,c));
    // }
/*********************************************PAIR********************************************************/
    static class Pair implements Comparable<Pair> {
        int u;
        int v;
        int index=-1;
        public Pair(int u, int v) {
            this.u = u;
            this.v = v;
        }
        public int hashCode() {
            int hu = (int) (u ^ (u >>> 32));
            int hv = (int) (v ^ (v >>> 32));
            return 31 * hu + hv;
        }
        public boolean equals(Object o) {
            Pair other = (Pair) o;
            return u == other.u && v == other.v;
        }
        public int compareTo(Pair other) {
            if(index!=other.index)
                return Long.compare(index, other.index);
            return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);
        }
        public String toString() {
            return "[u=" + u + ", v=" + v + "]";
        }
    }
/******************************************Long Pair*******************************************************/
    static class Pairl implements Comparable<Pairl> {
            long u;
            long v;
            int index=-1;
            public Pairl(long u, long v) {
                this.u = u;
                this.v = v;
            }
            public int hashCode() {
                int hu = (int) (u ^ (u >>> 32));
                int hv = (int) (v ^ (v >>> 32));
                return 31 * hu + hv;
            }
            public boolean equals(Object o) {
                Pairl other = (Pairl) o;
                return u == other.u && v == other.v;
            }
            public int compareTo(Pairl other) {
                if(index!=other.index)
                    return Long.compare(index, other.index);
                return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);
            }
            public String toString() {
                return "[u=" + u + ", v=" + v + "]";
            }
        }
/*****************************************DEBUG***********************************************************/
    public static void debug(Object... o){
        System.out.println(Arrays.deepToString(o));
    }
/************************************MODULAR EXPONENTIATION***********************************************/
    static long modulo(long a,long b,long c){
        long x=1;
        long y=a%c;
        while(b > 0){
            if(b%2 == 1){
                x=(x*y)%c;
            }
            y = (y*y)%c; // squaring the base
            b /= 2;
        }
        return  x%c;
    }
/********************************************GCD**********************************************************/
    static long gcd(long x, long y){
        if(x==0)
            return y;
        if(y==0)
            return x;
        long r=0, a, b;
        a = (x > y) ? x : y; // a is greater number
        b = (x < y) ? x : y; // b is smaller number
        r = b;
        while(a % b != 0){
            r = a % b;
            a = b;
            b = r;
        }
        return r;
    }
/******************************************SIEVE**********************************************************/
    static void sieveMake(int n){
        sieve=new boolean[n];
        Arrays.fill(sieve,true);
        sieve[0]=false;
        sieve[1]=false;
        for(int i=2;i*i<n;i++){
            if(sieve[i]){
                for(int j=i*i;j<n;j+=i){
                    sieve[j]=false;
                }
            }
        }
        primes=new ArrayList<Integer>();
        for(int i=0;i<n;i++){
            if(sieve[i]){
                primes.add(i);
            }
        }
    }
/********************************************End***********************************************************/
}


import java.util.*;
import java.io.*;
import java.io.ObjectOutputStream.PutField;

public class codeforces {

	public static void main(String[] args) throws Exception {
	   String s=sc.next();
	  HashMap<Character,Long> hs=new HashMap<Character, Long>();
	  HashMap<String,Long> Hs=new HashMap<String, Long>();
	  HashMap<Character,Long> h=new HashMap<Character, Long>();
	   long m=0l;
	   for(int i=0;i<s.length();i++) {
		  hs.put(s.charAt(i), hs.getOrDefault(s.charAt(i),0l)+1);
		  h.put(s.charAt(i), 0l);
		  m=Math.max(m,hs.get(s.charAt(i)));
	   }

	   for(int i=0;i<s.length();i++) {
			  h.put(s.charAt(i), h.get(s.charAt(i))+1);

				  for(char S:hs.keySet()) {

						  Hs.put(s.charAt(i)+""+S,Hs.getOrDefault(s.charAt(i)+""+S,0l)+(hs.get(S)-h.get(S)));
						  m=Math.max(m, Hs.get(s.charAt(i)+""+S));

		   }

				  }
		pw.println(m);

       pw.close();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(FileReader r) {
			br = new BufferedReader(r);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
	public static long GCD(long a, long b) {
		if(b==0)return a;
		if(a==0)return b;
		return (a>b)?GCD(a%b, b):GCD(a, b%a);
	}
	public static long LCM(long a, long b) {
		return a*b/GCD(a, b);
	}
	public static long nCk(int n, int k) { //O(K)
		if (k > n) {
			return 0;
		}
		long res = 1;
		for(int i = 1; i<=k; i++) {
			res = (n - k + i) * res/i;
		}
		return res;
	}
	public static long C(int a, int b, long[][] s) {
		int m = (int) 1e9 + 7;
		if (s[a][b] >= 0) {
			return s[a][b];
		} else if (a < b | a < 0 | b < 0) {
			s[a][b] = 0;
			return 0;
		} else if (a == b | b == 0) {
			s[a][b] = 1;
			return 1;
		} else {
			return s[a][b] = (C(a - 1, b, s) % m + C(a - 1, b - 1, s) % m) % m;
		}

	}
	static class pair implements Comparable<pair>  {
		int x;
		int y;
		public pair(int x,int y) {
			this.x=x;
			this.y=y;
		}
		public String toString(){
			return x+" "+y;
		}
		public int compareTo(pair other) {
			if(this.x==other.x) {
				return this.y-other.y;
			}
			else {
				return this.x-other.x;
			}
		}
	}
	static Scanner sc = new Scanner(System.in);
	static PrintWriter pw=new PrintWriter(System.out);
}


import java.util.*;
import java.io.*;
import java.io.ObjectOutputStream.PutField;

public class codeforces {

	public static void main(String[] args) throws Exception {
	   String s=sc.next();
	  HashMap<Character,Integer> hs=new HashMap<Character, Integer>();
	  HashMap<String,Integer> Hs=new HashMap<String, Integer>();
	  HashMap<Character,Integer> h=new HashMap<Character, Integer>();
	   int m=0;
	   for(int i=0;i<s.length();i++) {
		  hs.put(s.charAt(i), hs.getOrDefault(s.charAt(i),0)+1);
		  h.put(s.charAt(i), 0);
		  m=Math.max(m,hs.get(s.charAt(i)));
	   }

	   for(int i=0;i<s.length();i++) {
				  for(char S:hs.keySet()) {
					  if(S!=s.charAt(i)) {
						  Hs.put(s.charAt(i)+""+S,Hs.getOrDefault(s.charAt(i)+""+S,0)+(hs.get(S)-h.get(S)));
						  m=Math.max(m, Hs.get(s.charAt(i)+""+S));
					  }

		   }
				  h.put(s.charAt(i), h.get(s.charAt(i))+1);

				  }
		pw.println(m);

       pw.close();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(FileReader r) {
			br = new BufferedReader(r);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
	public static long GCD(long a, long b) {
		if(b==0)return a;
		if(a==0)return b;
		return (a>b)?GCD(a%b, b):GCD(a, b%a);
	}
	public static long LCM(long a, long b) {
		return a*b/GCD(a, b);
	}
	public static long nCk(int n, int k) { //O(K)
		if (k > n) {
			return 0;
		}
		long res = 1;
		for(int i = 1; i<=k; i++) {
			res = (n - k + i) * res/i;
		}
		return res;
	}
	public static long C(int a, int b, long[][] s) {
		int m = (int) 1e9 + 7;
		if (s[a][b] >= 0) {
			return s[a][b];
		} else if (a < b | a < 0 | b < 0) {
			s[a][b] = 0;
			return 0;
		} else if (a == b | b == 0) {
			s[a][b] = 1;
			return 1;
		} else {
			return s[a][b] = (C(a - 1, b, s) % m + C(a - 1, b - 1, s) % m) % m;
		}

	}
	static class pair implements Comparable<pair>  {
		int x;
		int y;
		public pair(int x,int y) {
			this.x=x;
			this.y=y;
		}
		public String toString(){
			return x+" "+y;
		}
		public int compareTo(pair other) {
			if(this.x==other.x) {
				return this.y-other.y;
			}
			else {
				return this.x-other.x;
			}
		}
	}
	static Scanner sc = new Scanner(System.in);
	static PrintWriter pw=new PrintWriter(System.out);
}


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

public class codeforces {

	public static void main(String[] args) throws Exception {
	   String s=sc.next();
	   HashMap<String,Integer> hs=new HashMap<String, Integer>();
	   int m=0;
	   for(int i=0;i<s.length();i++) {
		  hs.put(s.charAt(i)+"", hs.getOrDefault(s.charAt(i)+"",0)+1);
		  m=Math.max(m,hs.get(s.charAt(i)+""));
	   }
	   for(int i=0;i<s.length();i++) {
		   if(hs.containsKey(s.charAt(i)+"")) {
			  for(int j=i+1;j<s.length();j++) {
				  hs.put(s.charAt(i)+""+s.charAt(j), hs.getOrDefault(s.charAt(i)+""+s.charAt(j),0)+1);
				  m=Math.max(m,hs.get(s.charAt(i)+""+s.charAt(j)));
			  }
		   }}
		pw.println(m);

       pw.close();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(FileReader r) {
			br = new BufferedReader(r);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
	public static long GCD(long a, long b) {
		if(b==0)return a;
		if(a==0)return b;
		return (a>b)?GCD(a%b, b):GCD(a, b%a);
	}
	public static long LCM(long a, long b) {
		return a*b/GCD(a, b);
	}
	public static long nCk(int n, int k) { //O(K)
		if (k > n) {
			return 0;
		}
		long res = 1;
		for(int i = 1; i<=k; i++) {
			res = (n - k + i) * res/i;
		}
		return res;
	}
	public static long C(int a, int b, long[][] s) {
		int m = (int) 1e9 + 7;
		if (s[a][b] >= 0) {
			return s[a][b];
		} else if (a < b | a < 0 | b < 0) {
			s[a][b] = 0;
			return 0;
		} else if (a == b | b == 0) {
			s[a][b] = 1;
			return 1;
		} else {
			return s[a][b] = (C(a - 1, b, s) % m + C(a - 1, b - 1, s) % m) % m;
		}

	}
	static class pair implements Comparable<pair>  {
		int x;
		int y;
		public pair(int x,int y) {
			this.x=x;
			this.y=y;
		}
		public String toString(){
			return x+" "+y;
		}
		public int compareTo(pair other) {
			if(this.x==other.x) {
				return this.y-other.y;
			}
			else {
				return this.x-other.x;
			}
		}
	}
	static Scanner sc = new Scanner(System.in);
	static PrintWriter pw=new PrintWriter(System.out);
}


import java.util.*;
import java.io.*;
import java.io.ObjectOutputStream.PutField;

public class codeforces {

	public static void main(String[] args) throws Exception {
	   String s=sc.next();
	  HashMap<Character,Integer> hs=new HashMap<Character, Integer>();
	  HashMap<String,Integer> Hs=new HashMap<String, Integer>();
	  HashMap<Character,Integer> h=new HashMap<Character, Integer>();
	   int m=0;
	   for(int i=0;i<s.length();i++) {
		  hs.put(s.charAt(i), hs.getOrDefault(s.charAt(i),0)+1);
		  h.put(s.charAt(i), 0);
		  m=Math.max(m,hs.get(s.charAt(i)));
	   }

	   for(int i=0;i<s.length();i++) {
			  h.put(s.charAt(i), h.get(s.charAt(i))+1);

				  for(char S:hs.keySet()) {

						  Hs.put(s.charAt(i)+""+S,Hs.getOrDefault(s.charAt(i)+""+S,0)+(hs.get(S)-h.get(S)));
						  m=Math.max(m, Hs.get(s.charAt(i)+""+S));

		   }

				  }
		pw.println(m);

       pw.close();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(FileReader r) {
			br = new BufferedReader(r);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
	public static long GCD(long a, long b) {
		if(b==0)return a;
		if(a==0)return b;
		return (a>b)?GCD(a%b, b):GCD(a, b%a);
	}
	public static long LCM(long a, long b) {
		return a*b/GCD(a, b);
	}
	public static long nCk(int n, int k) { //O(K)
		if (k > n) {
			return 0;
		}
		long res = 1;
		for(int i = 1; i<=k; i++) {
			res = (n - k + i) * res/i;
		}
		return res;
	}
	public static long C(int a, int b, long[][] s) {
		int m = (int) 1e9 + 7;
		if (s[a][b] >= 0) {
			return s[a][b];
		} else if (a < b | a < 0 | b < 0) {
			s[a][b] = 0;
			return 0;
		} else if (a == b | b == 0) {
			s[a][b] = 1;
			return 1;
		} else {
			return s[a][b] = (C(a - 1, b, s) % m + C(a - 1, b - 1, s) % m) % m;
		}

	}
	static class pair implements Comparable<pair>  {
		int x;
		int y;
		public pair(int x,int y) {
			this.x=x;
			this.y=y;
		}
		public String toString(){
			return x+" "+y;
		}
		public int compareTo(pair other) {
			if(this.x==other.x) {
				return this.y-other.y;
			}
			else {
				return this.x-other.x;
			}
		}
	}
	static Scanner sc = new Scanner(System.in);
	static PrintWriter pw=new PrintWriter(System.out);
}


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

public class codeforces {

	public static void main(String[] args) throws Exception {
	   String s=sc.next();
	   HashMap<String,Integer> hs=new HashMap<String, Integer>();
	   int m=0;
	   for(int i=0;i<s.length();i++) {
		  hs.put(s.charAt(i)+"", hs.getOrDefault(s.charAt(i)+"",0)+1);
		  m=Math.max(m,hs.get(s.charAt(i)+""));
	   }
	   for(int i=0;i<s.length();i++) {
			  for(int j=i+1;j<s.length();j++) {
				  hs.put(s.charAt(i)+""+s.charAt(j), hs.getOrDefault(s.charAt(i)+""+s.charAt(j),0)+1);
				  m=Math.max(m,hs.get(s.charAt(i)+""+s.charAt(j)));
			  }
		   }
		pw.println(m);

       pw.close();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(FileReader r) {
			br = new BufferedReader(r);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
	public static long GCD(long a, long b) {
		if(b==0)return a;
		if(a==0)return b;
		return (a>b)?GCD(a%b, b):GCD(a, b%a);
	}
	public static long LCM(long a, long b) {
		return a*b/GCD(a, b);
	}
	public static long nCk(int n, int k) { //O(K)
		if (k > n) {
			return 0;
		}
		long res = 1;
		for(int i = 1; i<=k; i++) {
			res = (n - k + i) * res/i;
		}
		return res;
	}
	public static long C(int a, int b, long[][] s) {
		int m = (int) 1e9 + 7;
		if (s[a][b] >= 0) {
			return s[a][b];
		} else if (a < b | a < 0 | b < 0) {
			s[a][b] = 0;
			return 0;
		} else if (a == b | b == 0) {
			s[a][b] = 1;
			return 1;
		} else {
			return s[a][b] = (C(a - 1, b, s) % m + C(a - 1, b - 1, s) % m) % m;
		}

	}
	static class pair implements Comparable<pair>  {
		int x;
		int y;
		public pair(int x,int y) {
			this.x=x;
			this.y=y;
		}
		public String toString(){
			return x+" "+y;
		}
		public int compareTo(pair other) {
			if(this.x==other.x) {
				return this.y-other.y;
			}
			else {
				return this.x-other.x;
			}
		}
	}
	static Scanner sc = new Scanner(System.in);
	static PrintWriter pw=new PrintWriter(System.out);
}


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

public class codeforces {

	public static void main(String[] args) throws Exception {
	   String s=sc.next();
	  TreeMap<String,Integer> hs=new TreeMap<String, Integer>(Collections.reverseOrder());
	   int m=0;
	   for(int i=0;i<s.length();i++) {
		  hs.put(s.charAt(i)+"", hs.getOrDefault(s.charAt(i)+"",0)+1);
		  m=Math.max(m,hs.get(s.charAt(i)+""));
	   }
	   if (hs.size()==1) {
		   pw.println(hs.remove(hs.firstKey()));
	   }
	   else {
		   pw.println(hs.remove(hs.firstKey())*hs.remove(hs.firstKey()));
	   }

       pw.close();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(FileReader r) {
			br = new BufferedReader(r);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
	public static long GCD(long a, long b) {
		if(b==0)return a;
		if(a==0)return b;
		return (a>b)?GCD(a%b, b):GCD(a, b%a);
	}
	public static long LCM(long a, long b) {
		return a*b/GCD(a, b);
	}
	public static long nCk(int n, int k) { //O(K)
		if (k > n) {
			return 0;
		}
		long res = 1;
		for(int i = 1; i<=k; i++) {
			res = (n - k + i) * res/i;
		}
		return res;
	}
	public static long C(int a, int b, long[][] s) {
		int m = (int) 1e9 + 7;
		if (s[a][b] >= 0) {
			return s[a][b];
		} else if (a < b | a < 0 | b < 0) {
			s[a][b] = 0;
			return 0;
		} else if (a == b | b == 0) {
			s[a][b] = 1;
			return 1;
		} else {
			return s[a][b] = (C(a - 1, b, s) % m + C(a - 1, b - 1, s) % m) % m;
		}

	}
	static class pair implements Comparable<pair>  {
		int x;
		int y;
		public pair(int x,int y) {
			this.x=x;
			this.y=y;
		}
		public String toString(){
			return x+" "+y;
		}
		public int compareTo(pair other) {
			if(this.x==other.x) {
				return this.y-other.y;
			}
			else {
				return this.x-other.x;
			}
		}
	}
	static Scanner sc = new Scanner(System.in);
	static PrintWriter pw=new PrintWriter(System.out);
}


import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;

public class k{

	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
	   String str=s.next();
	   ArrayList<Integer> list=new ArrayList<>();
	   HashMap<Character,Integer>map=new HashMap<>();
	   map.put(str.charAt(0), 1);
	   for(int i=1;i<str.length();i++) {
		   if(map.containsKey(str.charAt(i))) {
			   map.put(str.charAt(i), map.get(str.charAt(i))+1);
		   }else {
			   list.add(map.get(str.charAt(i-1)));
			   map.clear();
			   map.put(str.charAt(i), 1);
			   }
	   }
	   list.add(map.get(str.charAt(str.length()-1)));
	   //System.out.println(list);
		Collections.sort(list);
		long ans=0;
		int[] arr=new int[26];

		for(int i=0;i<str.length();i++) {
			arr[Integer.valueOf(str.charAt(i))-97]++;
		}
	   long max=-1;
	   for(int i=0;i<26;i++) {
		   if(max<arr[i]) {
			   max=arr[i];
		   }
	   }

	   System.out.println(Math.max(max, list.get(list.size()-1)*list.get(list.size()-2)));
	}
}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;

public class k {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String str = s.next();

		int n = str.length();

		long[][] dp = new long[26][str.length() + 1];
		dp[Integer.valueOf(str.charAt(n-1) - 97)][n - 1]++;
		for (int i = n - 2; i >= 0; i--) {
			int curr = str.charAt(i) - 'a';

			for (int j = 0; j < 26; j++) {
				if (j == curr) {
					dp[j][i] = dp[j][i + 1] + 1;
				} else {
					dp[j][i] = dp[j][i + 1];
				}
			}
		}

		ArrayList<Long> list = new ArrayList<>();

		for (int i = 0; i < 26; i++) {

			for (int j = 0; j < 26; j++) {
				long abc = 0;

				for (int k = 0; k < n; k++) {
					if (str.charAt(k) - 'a' == i) {
						abc = abc + dp[j][k + 1];
					}
				}

				list.add(abc);
			}
		}

//		for(int i=0;i<26;i++)
//		{
//			for(int j=0;j<n;j++)
//			{
//				System.out.print(dp[i][j]+" ");
//			}
//			System.out.println();
//		}

		long max = -1;
		for (int i = 0; i < 26; i++) {
			if (max < dp[i][0]) {
				max = dp[i][0];
			}
		}

		Collections.sort(list);
		System.out.println(Math.max(max, list.get(list.size() - 1)));

	}
}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;

public class k{

	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
	   String str=s.next();

	   int n=str.length();

	   int[][] dp=new int[26][str.length()+1];
	   dp[Integer.valueOf(str.charAt(0)-97)][n-1]++;
	   for(int i=n-2;i>=0;i--)
	   {
		   int curr=str.charAt(i)-'a';

		   for(int j=0;j<26;j++)
		   {
			   if(j==curr)
			   {
				   dp[j][i]=dp[j][i+1]+1;
			   }else {
				   dp[j][i]=dp[j][i+1];
			   }
		   }
	   }

	   ArrayList<Integer> list=new ArrayList<>();

	   for(int i=0;i<26;i++)
	   {

		   for(int j=0;j<26;j++)
		   {
			   int abc=0;

			   for(int k=0;k<n;k++)
			   {
				   if(str.charAt(k)-'a'==i)
				   {
					   abc=abc+dp[j][k+1];
				   }
			   }

			   list.add(abc);
		   }
	   }

	   int max=-1;
	   for(int i=0;i<26;i++) {
		   if(max<dp[i][0]) {
			   max=dp[i][0];
		   }
	   }

	   Collections.sort(list);
	   System.out.println(Math.max(max, list.get(list.size()-1)));

	}
}


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

public class C {
	private static FastReader fr;
	private static OutputStream out;
	private static int mod = (int)(1e9+7);

	private void solve() {
		char ch[] = fr.next().toCharArray();
		int freq[] = new int[26];
		int ans = 0;
		int n = ch.length;
		for(int i=0;i<n;i++) {
			int idx = ch[i] - 'a';
			freq[idx] ++;
			ans = Math.max(ans, freq[idx]);
		}

		freq = new int[26];
		HashMap<String, Integer> map = new HashMap<>();

		for(int i=0;i<n;i++) {
			int idx = ch[i] - 'a';
			freq[idx] ++;

			for(int j=0;j<26;j++) {
				if(j != idx && freq[j] > 0) {
					String s = (char)('a' + j) + "" + ch[i];
					if(map.containsKey(s)) {
						map.put(s, map.get(s) + freq[j]);
					}else {
						map.put(s, freq[j]);
					}
				}
			}

		}

		for(String s: map.keySet()) {
			ans = Math.max(ans, map.get(s));
		}
		println(ans);
	}

	public static void main(String args[]) throws IOException{
		new C().run();
	}

	private ArrayList<Integer> factors(int n, boolean include){
		ArrayList<Integer> factors = new ArrayList<>();
		if(n < 0)
			return factors;

		if(include) {
			factors.add(1);
			if(n > 1)
				factors.add(n);
		}

		int i = 2;
		for(;i*i<n;i++) {
			if(n % i == 0) {
				factors.add(i);
				factors.add(n / i);
			}
		}

		if(i * i == n) {
			factors.add(i);
		}

		return factors;
	}

	private ArrayList<Integer> PrimeFactors(int n) {
	    ArrayList<Integer> primes = new ArrayList<>();

	    int i = 2;
	    while (i * i <= n) {
	      if (n % i == 0) {
	        primes.add(i);

	        while (n % i == 0) {
	          n /= i;
	        }
	      }

	      i++;
	    }

	    if (n > 1) {
	      primes.add(n);
	    }

	    return primes;
	  }

	private boolean isPrime(int n) {
		if(n == 0 || n == 1) {
			return false;
		}

		if(n % 2 == 0) {
			return false;
		}

		for(int i=3;i*i<=n;i+=2) {
			if(n % i == 0) {
				return false;
			}
		}

		return true;
	}

	private ArrayList<Integer> Sieve(int n){
		boolean bool[] = new boolean[n+1];
		Arrays.fill(bool, true);
		bool[0] = bool[1] = false;

		for(int i=2;i*i<=n;i++) {
			if(bool[i]) {
				int j = 2;
				while(i*j <= n) {
					bool[i*j] = false;
					j++;
				}
			}
		}

		ArrayList<Integer> primes = new ArrayList<>();
		for(int i=2;i<=n;i++) {
			if(bool[i])
				primes.add(i);
		}

		return primes;
	}

	private HashMap<Integer, Integer> addToHashMap(HashMap<Integer, Integer> map, int arr[]){
		for(int val: arr) {
			if(!map.containsKey(val)) {
				map.put(val, 1);
			}else {
				map.put(val, map.get(val) + 1);
			}
		}
		return map;
	}

	private int factorial(int n) {
		long fac = 1;
		for(int i=2;i<=n;i++) {
			fac *= i;
			fac %= mod;
		}
		return (int)(fac % mod);
	}

	private static int pow(int base,int exp){
		if(exp == 0){
			return 1;
		}else if(exp == 1){
			return base;
		}
		int a = pow(base,exp/2);
		a = ((a % mod) * (a % mod)) % mod;
		if(exp % 2 == 1) {
			a = ((a % mod) * (base % mod));
		}
		return a;
	}

	private static int gcd(int a,int b){
		if(a == 0){
			return b;
		}

		return gcd(b%a,a);
	}

	private static int lcm(int a,int b){
		return (a * b)/gcd(a,b);
	}

	private void run() throws IOException{
		fr = new FastReader();
		out = new BufferedOutputStream(System.out);
		solve();
		out.flush();
		out.close();
	}

	private static class FastReader{
		private static BufferedReader br;
		private static StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new BufferedOutputStream(System.out);
		}

		public String next() {
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		public String nextLine() {
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public char[] nextCharArray() {
			return next().toCharArray();
		}

		public int[] nextIntArray(int n) {
			int arr[] = new int[n];
			for(int i=0;i<n;i++) {
				arr[i] = nextInt();
			}
			return arr;
		}

		public long[] nextLongArray(int n) {
			long arr[] = new long[n];
			for(int i=0;i<n;i++) {
				arr[i] = nextLong();
			}
			return arr;
		}

		public String[] nextStringArray(int n) {
			String arr[] = new String[n];
			for(int i=0;i<n;i++) {
				arr[i] = next();
			}
			return arr;
		}

	}

	public static void print(Object str) {
        try {
            out.write(str.toString().getBytes());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

	public static void println(Object str) {
        try {
            out.write((str.toString() + "\n").getBytes());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

	public static void println() {
		println("");
	}

	public static void printArray(Object str[]){
		for(Object s : str) {
			try {
	            out.write(str.toString().getBytes());
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
		}
	}
}


// package Contest1307;

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

public class C {
	private static FastReader fr;
	private static OutputStream out;
	private static int mod = (int)(1e9+7);

	private void solve() {
		char ch[] = fr.next().toCharArray();
		int freq[] = new int[26];
		long ans = 0;
		int n = ch.length;
		for(int i=0;i<n;i++) {
			int idx = ch[i] - 'a';
			freq[idx] ++;
			ans = Math.max(ans, (long)freq[idx]);
		}

		freq = new int[26];
		HashMap<String, Long> map = new HashMap<>();

		for(int i=0;i<n;i++) {
			int idx = ch[i] - 'a';

			for(int j=0;j<26;j++) {
				if(freq[j] > 0) {
					String s = (char)('a' + j) + "" + ch[i];
					if(map.containsKey(s)) {
						map.put(s, map.get(s) + (long)freq[j]);
					}else {
						map.put(s, (long)freq[j]);
					}
				}
			}
			freq[idx] ++;
		}

		for(String s: map.keySet()) {
			ans = Math.max(ans, map.get(s));
		}
		println(ans);
	}

	public static void main(String args[]) throws IOException{
		new C().run();
	}

	private ArrayList<Integer> factors(int n, boolean include){
		ArrayList<Integer> factors = new ArrayList<>();
		if(n < 0)
			return factors;

		if(include) {
			factors.add(1);
			if(n > 1)
				factors.add(n);
		}

		int i = 2;
		for(;i*i<n;i++) {
			if(n % i == 0) {
				factors.add(i);
				factors.add(n / i);
			}
		}

		if(i * i == n) {
			factors.add(i);
		}

		return factors;
	}

	private ArrayList<Integer> PrimeFactors(int n) {
	    ArrayList<Integer> primes = new ArrayList<>();

	    int i = 2;
	    while (i * i <= n) {
	      if (n % i == 0) {
	        primes.add(i);

	        while (n % i == 0) {
	          n /= i;
	        }
	      }

	      i++;
	    }

	    if (n > 1) {
	      primes.add(n);
	    }

	    return primes;
	  }

	private boolean isPrime(int n) {
		if(n == 0 || n == 1) {
			return false;
		}

		if(n % 2 == 0) {
			return false;
		}

		for(int i=3;i*i<=n;i+=2) {
			if(n % i == 0) {
				return false;
			}
		}

		return true;
	}

	private ArrayList<Integer> Sieve(int n){
		boolean bool[] = new boolean[n+1];
		Arrays.fill(bool, true);
		bool[0] = bool[1] = false;

		for(int i=2;i*i<=n;i++) {
			if(bool[i]) {
				int j = 2;
				while(i*j <= n) {
					bool[i*j] = false;
					j++;
				}
			}
		}

		ArrayList<Integer> primes = new ArrayList<>();
		for(int i=2;i<=n;i++) {
			if(bool[i])
				primes.add(i);
		}

		return primes;
	}

	private HashMap<Integer, Integer> addToHashMap(HashMap<Integer, Integer> map, int arr[]){
		for(int val: arr) {
			if(!map.containsKey(val)) {
				map.put(val, 1);
			}else {
				map.put(val, map.get(val) + 1);
			}
		}
		return map;
	}

	private int factorial(int n) {
		long fac = 1;
		for(int i=2;i<=n;i++) {
			fac *= i;
			fac %= mod;
		}
		return (int)(fac % mod);
	}

	private static int pow(int base,int exp){
		if(exp == 0){
			return 1;
		}else if(exp == 1){
			return base;
		}
		int a = pow(base,exp/2);
		a = ((a % mod) * (a % mod)) % mod;
		if(exp % 2 == 1) {
			a = ((a % mod) * (base % mod));
		}
		return a;
	}

	private static int gcd(int a,int b){
		if(a == 0){
			return b;
		}

		return gcd(b%a,a);
	}

	private static int lcm(int a,int b){
		return (a * b)/gcd(a,b);
	}

	private void run() throws IOException{
		fr = new FastReader();
		out = new BufferedOutputStream(System.out);
		solve();
		out.flush();
		out.close();
	}

	private static class FastReader{
		private static BufferedReader br;
		private static StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new BufferedOutputStream(System.out);
		}

		public String next() {
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		public String nextLine() {
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public char[] nextCharArray() {
			return next().toCharArray();
		}

		public int[] nextIntArray(int n) {
			int arr[] = new int[n];
			for(int i=0;i<n;i++) {
				arr[i] = nextInt();
			}
			return arr;
		}

		public long[] nextLongArray(int n) {
			long arr[] = new long[n];
			for(int i=0;i<n;i++) {
				arr[i] = nextLong();
			}
			return arr;
		}

		public String[] nextStringArray(int n) {
			String arr[] = new String[n];
			for(int i=0;i<n;i++) {
				arr[i] = next();
			}
			return arr;
		}

	}

	public static void print(Object str) {
        try {
            out.write(str.toString().getBytes());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

	public static void println(Object str) {
        try {
            out.write((str.toString() + "\n").getBytes());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

	public static void println() {
		println("");
	}

	public static void printArray(Object str[]){
		for(Object s : str) {
			try {
	            out.write(str.toString().getBytes());
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
		}
	}
}


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

public class C {
	private static FastReader fr;
	private static OutputStream out;
	private static int mod = (int)(1e9+7);

	private void solve() {
		char ch[] = fr.next().toCharArray();
		int freq[] = new int[26];
		int ans = 0;
		int n = ch.length;
		for(int i=0;i<n;i++) {
			int idx = ch[i] - 'a';
			freq[idx] ++;
			ans = Math.max(ans, freq[idx]);
		}

		freq = new int[26];
		HashMap<String, Integer> map = new HashMap<>();

		for(int i=0;i<n;i++) {
			int idx = ch[i] - 'a';

			for(int j=0;j<26;j++) {
				if(freq[j] > 0) {
					String s = (char)('a' + j) + "" + ch[i];
					if(map.containsKey(s)) {
						map.put(s, map.get(s) + freq[j]);
					}else {
						map.put(s, freq[j]);
					}
				}
			}
			freq[idx] ++;
		}

		for(String s: map.keySet()) {
			ans = Math.max(ans, map.get(s));
		}
		println(ans);
	}

	public static void main(String args[]) throws IOException{
		new C().run();
	}

	private ArrayList<Integer> factors(int n, boolean include){
		ArrayList<Integer> factors = new ArrayList<>();
		if(n < 0)
			return factors;

		if(include) {
			factors.add(1);
			if(n > 1)
				factors.add(n);
		}

		int i = 2;
		for(;i*i<n;i++) {
			if(n % i == 0) {
				factors.add(i);
				factors.add(n / i);
			}
		}

		if(i * i == n) {
			factors.add(i);
		}

		return factors;
	}

	private ArrayList<Integer> PrimeFactors(int n) {
	    ArrayList<Integer> primes = new ArrayList<>();

	    int i = 2;
	    while (i * i <= n) {
	      if (n % i == 0) {
	        primes.add(i);

	        while (n % i == 0) {
	          n /= i;
	        }
	      }

	      i++;
	    }

	    if (n > 1) {
	      primes.add(n);
	    }

	    return primes;
	  }

	private boolean isPrime(int n) {
		if(n == 0 || n == 1) {
			return false;
		}

		if(n % 2 == 0) {
			return false;
		}

		for(int i=3;i*i<=n;i+=2) {
			if(n % i == 0) {
				return false;
			}
		}

		return true;
	}

	private ArrayList<Integer> Sieve(int n){
		boolean bool[] = new boolean[n+1];
		Arrays.fill(bool, true);
		bool[0] = bool[1] = false;

		for(int i=2;i*i<=n;i++) {
			if(bool[i]) {
				int j = 2;
				while(i*j <= n) {
					bool[i*j] = false;
					j++;
				}
			}
		}

		ArrayList<Integer> primes = new ArrayList<>();
		for(int i=2;i<=n;i++) {
			if(bool[i])
				primes.add(i);
		}

		return primes;
	}

	private HashMap<Integer, Integer> addToHashMap(HashMap<Integer, Integer> map, int arr[]){
		for(int val: arr) {
			if(!map.containsKey(val)) {
				map.put(val, 1);
			}else {
				map.put(val, map.get(val) + 1);
			}
		}
		return map;
	}

	private int factorial(int n) {
		long fac = 1;
		for(int i=2;i<=n;i++) {
			fac *= i;
			fac %= mod;
		}
		return (int)(fac % mod);
	}

	private static int pow(int base,int exp){
		if(exp == 0){
			return 1;
		}else if(exp == 1){
			return base;
		}
		int a = pow(base,exp/2);
		a = ((a % mod) * (a % mod)) % mod;
		if(exp % 2 == 1) {
			a = ((a % mod) * (base % mod));
		}
		return a;
	}

	private static int gcd(int a,int b){
		if(a == 0){
			return b;
		}

		return gcd(b%a,a);
	}

	private static int lcm(int a,int b){
		return (a * b)/gcd(a,b);
	}

	private void run() throws IOException{
		fr = new FastReader();
		out = new BufferedOutputStream(System.out);
		solve();
		out.flush();
		out.close();
	}

	private static class FastReader{
		private static BufferedReader br;
		private static StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new BufferedOutputStream(System.out);
		}

		public String next() {
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		public String nextLine() {
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public char[] nextCharArray() {
			return next().toCharArray();
		}

		public int[] nextIntArray(int n) {
			int arr[] = new int[n];
			for(int i=0;i<n;i++) {
				arr[i] = nextInt();
			}
			return arr;
		}

		public long[] nextLongArray(int n) {
			long arr[] = new long[n];
			for(int i=0;i<n;i++) {
				arr[i] = nextLong();
			}
			return arr;
		}

		public String[] nextStringArray(int n) {
			String arr[] = new String[n];
			for(int i=0;i<n;i++) {
				arr[i] = next();
			}
			return arr;
		}

	}

	public static void print(Object str) {
        try {
            out.write(str.toString().getBytes());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

	public static void println(Object str) {
        try {
            out.write((str.toString() + "\n").getBytes());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

	public static void println() {
		println("");
	}

	public static void printArray(Object str[]){
		for(Object s : str) {
			try {
	            out.write(str.toString().getBytes());
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
		}
	}
}


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

public class C {
	private static FastReader fr;
	private static OutputStream out;
	private static int mod = (int)(1e9+7);

	private void solve() {
		char ch[] = fr.next().toCharArray();
		int freq[] = new int[26];
		int ans = 0;
		int n = ch.length;
		for(int i=0;i<n;i++) {
			int idx = ch[i] - 'a';
			freq[idx] ++;
			ans = Math.max(ans, freq[idx]);
		}

		freq = new int[26];
		HashMap<String, Integer> map = new HashMap<>();
		for(int i=0;i<n;i++) {
			int idx = ch[i] - 'a';
			freq[idx] ++;
			int a = 0;
			int b = freq[idx];
			char c = '0';
			for(int j=0;j<26;j++) {
				if(j != idx && freq[j] > 0) {
					String s = (char)('a' + j) + "" + ch[i];
					if(map.containsKey(s)) {
						map.put(s, map.get(s) + freq[j]);
					}else {
						map.put(s, freq[idx] * freq[j]);
					}
				}
			}
		}

		for(String s: map.keySet()) {
			ans = Math.max(ans, map.get(s));
		}
		println(ans);
	}

	public static void main(String args[]) throws IOException{
		new C().run();
	}

	private ArrayList<Integer> factors(int n, boolean include){
		ArrayList<Integer> factors = new ArrayList<>();
		if(n < 0)
			return factors;

		if(include) {
			factors.add(1);
			if(n > 1)
				factors.add(n);
		}

		int i = 2;
		for(;i*i<n;i++) {
			if(n % i == 0) {
				factors.add(i);
				factors.add(n / i);
			}
		}

		if(i * i == n) {
			factors.add(i);
		}

		return factors;
	}

	private ArrayList<Integer> PrimeFactors(int n) {
	    ArrayList<Integer> primes = new ArrayList<>();

	    int i = 2;
	    while (i * i <= n) {
	      if (n % i == 0) {
	        primes.add(i);

	        while (n % i == 0) {
	          n /= i;
	        }
	      }

	      i++;
	    }

	    if (n > 1) {
	      primes.add(n);
	    }

	    return primes;
	  }

	private boolean isPrime(int n) {
		if(n == 0 || n == 1) {
			return false;
		}

		if(n % 2 == 0) {
			return false;
		}

		for(int i=3;i*i<=n;i+=2) {
			if(n % i == 0) {
				return false;
			}
		}

		return true;
	}

	private ArrayList<Integer> Sieve(int n){
		boolean bool[] = new boolean[n+1];
		Arrays.fill(bool, true);
		bool[0] = bool[1] = false;

		for(int i=2;i*i<=n;i++) {
			if(bool[i]) {
				int j = 2;
				while(i*j <= n) {
					bool[i*j] = false;
					j++;
				}
			}
		}

		ArrayList<Integer> primes = new ArrayList<>();
		for(int i=2;i<=n;i++) {
			if(bool[i])
				primes.add(i);
		}

		return primes;
	}

	private HashMap<Integer, Integer> addToHashMap(HashMap<Integer, Integer> map, int arr[]){
		for(int val: arr) {
			if(!map.containsKey(val)) {
				map.put(val, 1);
			}else {
				map.put(val, map.get(val) + 1);
			}
		}
		return map;
	}

	private int factorial(int n) {
		long fac = 1;
		for(int i=2;i<=n;i++) {
			fac *= i;
			fac %= mod;
		}
		return (int)(fac % mod);
	}

	private static int pow(int base,int exp){
		if(exp == 0){
			return 1;
		}else if(exp == 1){
			return base;
		}
		int a = pow(base,exp/2);
		a = ((a % mod) * (a % mod)) % mod;
		if(exp % 2 == 1) {
			a = ((a % mod) * (base % mod));
		}
		return a;
	}

	private static int gcd(int a,int b){
		if(a == 0){
			return b;
		}

		return gcd(b%a,a);
	}

	private static int lcm(int a,int b){
		return (a * b)/gcd(a,b);
	}

	private void run() throws IOException{
		fr = new FastReader();
		out = new BufferedOutputStream(System.out);
		solve();
		out.flush();
		out.close();
	}

	private static class FastReader{
		private static BufferedReader br;
		private static StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new BufferedOutputStream(System.out);
		}

		public String next() {
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		public String nextLine() {
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public char[] nextCharArray() {
			return next().toCharArray();
		}

		public int[] nextIntArray(int n) {
			int arr[] = new int[n];
			for(int i=0;i<n;i++) {
				arr[i] = nextInt();
			}
			return arr;
		}

		public long[] nextLongArray(int n) {
			long arr[] = new long[n];
			for(int i=0;i<n;i++) {
				arr[i] = nextLong();
			}
			return arr;
		}

		public String[] nextStringArray(int n) {
			String arr[] = new String[n];
			for(int i=0;i<n;i++) {
				arr[i] = next();
			}
			return arr;
		}

	}

	public static void print(Object str) {
        try {
            out.write(str.toString().getBytes());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

	public static void println(Object str) {
        try {
            out.write((str.toString() + "\n").getBytes());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

	public static void println() {
		println("");
	}

	public static void printArray(Object str[]){
		for(Object s : str) {
			try {
	            out.write(str.toString().getBytes());
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
		}
	}
}


//package com.pb.codeforces.practice;

import java.util.Scanner;

public class CF1307C {

	public static long processCnt(int ch, int[] r, int[][] dp) {
		long cnt = 0;
		for(int i=0; i<26; i++) {
			dp[i][ch] += r[i];
			cnt = Math.max(cnt, dp[i][ch]);
		}
		return cnt;
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		char[] c = in.next().toCharArray();
		int[] r = new int[26];
		long mcnt = 0;
		for(int i=0; i<c.length; i++) {
			r[c[i]-'a']++;
			mcnt = Math.max(mcnt, r[c[i]-'a']);
		}
		int[][] dp = new int[26][26];
		for(int i=0; i<c.length; i++) {
			r[c[i]-'a']--;
			mcnt = Math.max(mcnt, processCnt(c[i]-'a',r,dp));
		}
		System.out.println(mcnt);
	}
}


//package com.pb.codeforces.practice;

import java.util.Scanner;

public class CF1307C {

	public static long processCnt(int ch, int[] r, long[][] dp) {
		long cnt = 0;
		for(int i=0; i<26; i++) {
			dp[i][ch] += r[i];
			cnt = Math.max(cnt, dp[i][ch]);
		}
		return cnt;
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		char[] c = in.next().toCharArray();
		int[] r = new int[26];
		long mcnt = 0;
		for(int i=0; i<c.length; i++) {
			r[c[i]-'a']++;
			mcnt = Math.max(mcnt, r[c[i]-'a']);
		}
		long[][] dp = new long[26][26];
		for(int i=0; i<c.length; i++) {
			r[c[i]-'a']--;
			mcnt = Math.max(mcnt, processCnt(c[i]-'a',r,dp));
		}
		System.out.println(mcnt);
	}
}


//package com.pb.codeforces.practice;

import java.util.Scanner;

public class CF1307C {

	public static long getCount(int n) {
		return (n * (n+1))/2;
	}

	public static long processCnt(int ch, int lcnt, int[] r) {
		long cnt = 0;
		for(int i=0; i<26; i++) {
			if(i != ch)
				cnt = Math.max(cnt, lcnt*r[i]);
			else
				cnt = Math.max(cnt, getCount(lcnt+r[i]-1));
		}
		return cnt;
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		char[] c = in.next().toCharArray();
		int[] r = new int[26];
		long mcnt = 0;
		for(int i=0; i<c.length; i++) {
			r[c[i]-'a']++;
			mcnt = Math.max(mcnt, r[c[i]-'a']);
		}
		int[] l = new int[26];
		for(int i=0; i<c.length; i++) {
			l[c[i]-'a']++;
			r[c[i]-'a']--;
			mcnt = Math.max(mcnt, processCnt(c[i]-'a',l[c[i]-'a'],r));
		}
		System.out.println(mcnt);
	}
}


//package CodeForces.C621;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Map;
import java.util.StringTokenizer;

public class C {
    public static void main(String[] args) {
        String q = in.next();

        int[] charCoun = new int[26];
        Arrays.fill(charCoun, 0);

        for (int i=0;i<q.length();i++) {
            charCoun[q.charAt(i)-'a']++;
        }

        long maxcoun = Arrays.stream(charCoun).max().getAsInt();

        for (int i=0;i<26;i++) {
            for (int j=i+1;j<26;j++) {
                long coun = 0;
                long c1c = 0;
                for (int k=0;k<q.length();k++) {
                    if (q.charAt(k) - 'a' == i) {
                        c1c++;
                    } else if (q.charAt(k)-'a' == j) {
                        coun += c1c;
                    }
                }
                maxcoun = Long.max(maxcoun, coun);
            }
        }
        out.println(maxcoun);
        out.close();
    }

    static InputStream inputStream = System.in;
    static OutputStream outputStream = System.out;
    static InputReader in = new InputReader(inputStream);
    static PrintWriter out = new PrintWriter(outputStream);

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int NI() {
            return Integer.parseInt(next());
        }

        public long NL() {
            return Long.parseLong(next());
        }

    }
}


//package CodeForces.C621;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Map;
import java.util.StringTokenizer;

public class C {
    public static void main(String[] args) {
        String q = in.next();

        int[] charCoun = new int[26];
        Arrays.fill(charCoun, 0);

        for (int i=0;i<q.length();i++) {
            charCoun[q.charAt(i)-'a']++;
        }

        long maxcoun = Arrays.stream(charCoun).max().getAsInt();

        for (int i=0;i<26;i++) {
            for (int j=0;j<26;j++) {
                long coun = 0;
                long c1c = 0;
                for (int k=0;k<q.length();k++) {
                    if (q.charAt(k) - 'a' == j) {
                        coun+=c1c;
                    }
                    if (q.charAt(k)-'a' == i) {
                        c1c++;
                    }
                }
                maxcoun = Long.max(maxcoun, coun);
            }
        }
        out.println(maxcoun);
        out.close();
    }

    static InputStream inputStream = System.in;
    static OutputStream outputStream = System.out;
    static InputReader in = new InputReader(inputStream);
    static PrintWriter out = new PrintWriter(outputStream);

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int NI() {
            return Integer.parseInt(next());
        }

        public long NL() {
            return Long.parseLong(next());
        }

    }
}


//package CodeForces.C621;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Map;
import java.util.StringTokenizer;

public class C {
    public static void main(String[] args) {
        String q = in.next();

        int[] charCoun = new int[26];
        Arrays.fill(charCoun, 0);

        for (int i=0;i<q.length();i++) {
            charCoun[q.charAt(i)-'a']++;
        }

        long maxcoun = Arrays.stream(charCoun).max().getAsInt();

        for (int i=0;i<26;i++) {
            for (int j=0;j<26;j++) {
                if (i==j) continue;;
                long coun = 0;
                long c1c = 0;
                for (int k=0;k<q.length();k++) {
                    if (q.charAt(k) - 'a' == i) {
                        c1c++;
                    } else if (q.charAt(k)-'a' == j) {
                        coun += c1c;
                    }
                }
                maxcoun = Long.max(maxcoun, coun);
            }
        }
        out.println(maxcoun);
        out.close();
    }

    static InputStream inputStream = System.in;
    static OutputStream outputStream = System.out;
    static InputReader in = new InputReader(inputStream);
    static PrintWriter out = new PrintWriter(outputStream);

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int NI() {
            return Integer.parseInt(next());
        }

        public long NL() {
            return Long.parseLong(next());
        }

    }
}


import java.util.Scanner;

public class C {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] list = new int[26];
        String s = sc.next();
        int[] frq = new int[26];
        long[][] occ = new long[26][26];
        long ans = 0 ;
        for(int i  = 0 ; i < s.length() ; i++)
        {
            int chr = s.charAt(i)-'a';
            for(int j = 0 ; j < 26 ; j++)
            {
                occ[j][chr] += frq[j];
            }
            frq[chr] ++;
        }
        for(int i = 0 ; i  <  26 ; i++)
        {
            ans = Math.max(ans , frq[i]);
            for(int j = 0 ; j <  26 ; j++)
            {
                ans = Math.max(occ[i][j],ans);
            }
        }
        System.out.println(ans);

    }
}


import java.util.Scanner;

public class C {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] list = new int[26];
        String s = sc.next();
        int[] frq = new int[26];
        int[][] occ = new int[26][26];
        int ans = 0 ;
        for(int i  = 0 ; i < s.length() ; i++)
        {
            int chr = s.charAt(i)-'a';
            for(int j = 0 ; j < 26 ; j++)
            {
                occ[j][chr] += frq[j];
            }
            frq[chr] ++;
        }
        for(int i = 0 ; i  <  26 ; i++)
        {
            ans = Math.max(ans , frq[i]);
            for(int j = 0 ; j <  26 ; j++)
            {
                ans = Math.max(occ[i][j],ans);
            }
        }
        System.out.println(ans);

    }
}


import java.util.Scanner;

public class C {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] list = new int[26];
        String s = sc.next();
        for(int i = 0 ; i < s.length();i++)
            list[s.charAt(i)-'a']++;
        long sum = 1;
        for(int i = 0 ; i < list.length ; i++)
        {
            sum*=list[i]==0?1:list[i];
        }
        System.out.println(sum);
    }
}


/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
*/
import java.util.*;
import java.io.*;

   public class C
   {
      public static void main(String omkar[]) throws Exception
      {
         //BufferedReader infile = new BufferedReader(new FileReader("cowdate.in"));
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         String input = st.nextToken();
         int N = input.length();
         char[] arr = input.toCharArray();
         int[] cnt = new int[300];
         for(char c: arr)
            cnt[c]++;
         //neighbor
         long res = 0L;
         char prev = '?';
         char curr = arr[0];
         int psize = 0;
         int csize = 1;
         for(int i=1; i < N; i++)
         {
            if(arr[i] != curr)
            {
               //calculate
               if(prev != '?')
                  res = Math.max(res, (long)psize*csize);
               prev = curr;
               psize = csize;
               curr = arr[i];
               csize = 1;
            }
            else
               csize++;
         }
         if(prev != '?')
            res = Math.max(res, (long)psize*csize);
         //singles, pascal
         for(char c: arr)
         {
            long size = cnt[c];
            res = Math.max(res, size*(size-1)/2);
            res = Math.max(res, size);
         }
         System.out.print(res);
      }
   }


/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
*/
import java.util.*;
import java.io.*;

   public class C
   {
      public static void main(String omkar[]) throws Exception
      {
         //BufferedReader infile = new BufferedReader(new FileReader("cowdate.in"));
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         String input = st.nextToken();
         int N = input.length();
         char[] arr = input.toCharArray();
         int[] cnt = new int[300];
         for(char c: arr)
            cnt[c]++;
         //neighbor
         long res = 0L;
         char prev = '?';
         char curr = arr[0];
         int psize = 0;
         int csize = 1;
         //
         ArrayList<Integer> sizes = new ArrayList<Integer>();
         for(int i=1; i < N; i++)
         {
            if(arr[i] != curr)
            {
               //calculate
               if(prev != '?')
                  res = Math.max(res, (long)psize*csize);
               sizes.add(csize);
               prev = curr;
               psize = csize;
               curr = arr[i];
               csize = 1;
            }
            else
               csize++;
         }
         if(prev != '?')
            res = Math.max(res, (long)psize*csize);
         sizes.add(csize);
         Collections.sort(sizes);
         if(sizes.size() >= 2)
            res = Math.max(res, (long)sizes.get(sizes.size()-1)*sizes.get(sizes.size()-2));
         //singles, pascal
         for(char c: arr)
         {
            long size = cnt[c];
            res = Math.max(res, size*(size-1)/2);
            res = Math.max(res, size);
         }
         System.out.print(res);
      }
   }


/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
*/
import java.util.*;
import java.io.*;

   public class C2
   {
      public static void main(String omkar[]) throws Exception
      {
         //BufferedReader infile = new BufferedReader(new FileReader("cowdate.in"));
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         String input = st.nextToken();
         int N = input.length();
         char[] arr = input.toCharArray();
         int[] cnt = new int[500];
         for(char c: arr)
            cnt[c]++;
         //neighbor
         long res = 0L;
         char prev = '?';
         char curr = arr[0];
         int psize = 0;
         int csize = 1;
         //
         ArrayList<Integer> sizes = new ArrayList<Integer>();
         for(int i=1; i < N; i++)
         {
            if(arr[i] != curr)
            {
               //calculate
               if(prev != '?')
                  res = Math.max(res, (long)psize*csize);
               sizes.add(csize);
               prev = curr;
               psize = csize;
               curr = arr[i];
               csize = 1;
            }
            else
               csize++;
         }
         if(prev != '?')
            res = Math.max(res, (long)psize*csize);
         sizes.add(csize);
         Collections.sort(sizes);
         if(sizes.size() >= 2)
            res = Math.max(res, (long)sizes.get(sizes.size()-1)*(long)sizes.get(sizes.size()-2));
         //cancer
         String alpha = "qazwsxedcrfvtgbyhnujmiklop";
         char[] boof = alpha.toCharArray();
         for(int a=0; a < 26; a++)
            for(int b=0; b < 26; b++)
            {
               if(a == b)
                  continue;
               long x = cnt[boof[a]];
               long y = cnt[boof[b]];
               long temp = 0L;
               for(int i=0; i < N; i++)
               {
                  if(arr[i] == boof[a])
                     temp += y;
                  else if(arr[i] == boof[b])
                     y--;
               }
               res = Math.max(res, temp);
            }
         //singles
         for(char c: arr)
         {
            long size = (long)cnt[c];
            res = Math.max(res, size*(size-1)/2);
            res = Math.max(res, size);
         }
         System.out.print(res);
      }
   }


/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
*/
import java.util.*;
import java.io.*;

   public class C
   {
      public static void main(String omkar[]) throws Exception
      {
         //BufferedReader infile = new BufferedReader(new FileReader("cowdate.in"));
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         String input = st.nextToken();
         int N = input.length();
         char[] arr = input.toCharArray();
         int[] cnt = new int[300];
         for(char c: arr)
            cnt[c]++;
         //neighbor
         long res = 0L;
         char prev = '?';
         char curr = arr[0];
         int psize = 0;
         int csize = 1;
         for(int i=1; i < N; i++)
         {
            if(arr[i] != curr)
            {
               //calculate
               if(prev != '?')
                  res = Math.max(res, (long)psize*csize);
               prev = curr;
               psize = csize;
               curr = arr[i];
               csize = 1;
            }
            else
               csize++;
         }
         if(prev != '?')
            res = Math.max(res, (long)psize*csize);
         //singles, pascal
         for(char c: arr)
         {
            long size = cnt[c];
            res = Math.max(res, size*(size-1)/2);
         }
         System.out.print(res);
      }
   }


import java.util.*;
import java.io.*;
import java.math.*;
public class C621{

	public static void main(String args[]){
        FastReader sc = new FastReader();
        int i,j,n,count;
        char s[]=sc.next().toCharArray();
        n=s.length;
        long f[]=new long[26];
        long a[][]=new long[26][26];
        for(i=0;i<n;i++)
            f[s[i]-'a']++;
        long max1=0;
        for(i=0;i<n;i++){
            int temp=s[i]-'a';
            max1=Math.max(max1,f[temp]);
            f[temp]--;
            for(j=0;j<26;j++)
                a[temp][j]+=f[j];

        }
        long max2=0;
        for(i=0;i<26;i++){

            for(j=0;j<26;j++)
                max2=Math.max(max2,a[i][j]);
        }
        long ans=Math.max(max1,max2);
        out.println(ans);
		out.flush();
	}

	static PrintWriter out;
	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br=new BufferedReader(new InputStreamReader(System.in));
			out=new PrintWriter(System.out);
		}
		String next(){
			while(st==null || !st.hasMoreElements()){
				try{
					st= new StringTokenizer(br.readLine());
				}
				catch (IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt(){
			return Integer.parseInt(next());
		}
		long nextLong(){
			return Long.parseLong(next());
		}
		double nextDouble(){
			return Double.parseDouble(next());
		}
		String nextLine(){
			String str = "";
			try{
				str=br.readLine();
			}
			catch(IOException e){
				e.printStackTrace();
			}
			return str;
		}
	}

	public static boolean isPrime(int n) {
		if(n<2) return false;
		for(int i=2;i<=(int)Math.sqrt(n);i++) {
			if(n%i==0) return false;
		}
		return true;
	}

	public static void print(int a[],int l,int r){
		int i;
		for(i=l;i<=r;i++)
			out.print(a[i]+" ");
		out.println();
	}

	public static long fastexpo(long x, long y, long p){
		long res=1;
		while(y > 0){
			if((y & 1)==1)
				res= ((res%p)*(x%p))%p;
			y= y >> 1;
			x = ((x%p)*(x%p))%p;
		}
		return res;
	}

	public static boolean[] sieve (int n) {
		boolean primes[]=new boolean[n+1];
		Arrays.fill(primes,true);
		primes[0]=primes[1]=false;
		for(int i=2;i*i<=n;i++){
			if(primes[i]){
				for(int j=i*i;j<=n;j+=i)
					primes[j]=false;
			}
		}
		return primes;
	}

	public static long gcd(long a,long b){
        return (BigInteger.valueOf(a).gcd(BigInteger.valueOf(b))).longValue();
    }

    public static void merge(int a[],int l,int m,int r){
        int n1,n2,i,j,k;
        n1=m-l+1;
        n2=r-m;

        int L[]=new int[n1];
        int R[]=new int[n2];

        for(i=0;i<n1;i++)
            L[i]=a[l+i];
        for(j=0;j<n2;j++)
            R[j]=a[m+1+j];

        i=0;j=0;

        k=l;
        while(i<n1&&j<n2){
            if(L[i]<=R[j]){
                a[k]=L[i];
                i++;
            }
            else{
                a[k]=R[j];
                j++;
            }
            k++;
        }

        while(i<n1){
            a[k]=L[i];
            i++;
            k++;
        }
        while(j<n2){
            a[k]=R[j];
            j++;
            k++;
        }
    }
    public static void sort(int a[],int l,int r){
        int m;
        if(l<r){
            m=(l+r)/2;
            sort(a,l,m);
            sort(a,m+1,r);
            merge(a,l,m,r);
        }
    }
}


import java.util.*;
import java.io.*;
import java.math.*;
public class C621{

	public static void main(String args[]){
        FastReader sc = new FastReader();
        int i,j,n,count;
        char s[]=sc.next().toCharArray();
        n=s.length;
        int f[]=new int[26];
        int a[][]=new int[26][26];
        for(i=0;i<n;i++)
            f[s[i]-'a']++;
        int max1=0;
        for(i=0;i<n;i++){
            int temp=s[i]-'a';
            max1=Math.max(max1,f[temp]);
            f[temp]--;
            for(j=0;j<26;j++)
                a[temp][j]+=f[j];

        }
        int max2=0;
        for(i=0;i<26;i++){

            for(j=0;j<26;j++)
                max2=Math.max(max2,a[i][j]);
        }
        int ans=Math.max(max1,max2);
        out.println(ans);
		out.flush();
	}

	static PrintWriter out;
	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br=new BufferedReader(new InputStreamReader(System.in));
			out=new PrintWriter(System.out);
		}
		String next(){
			while(st==null || !st.hasMoreElements()){
				try{
					st= new StringTokenizer(br.readLine());
				}
				catch (IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt(){
			return Integer.parseInt(next());
		}
		long nextLong(){
			return Long.parseLong(next());
		}
		double nextDouble(){
			return Double.parseDouble(next());
		}
		String nextLine(){
			String str = "";
			try{
				str=br.readLine();
			}
			catch(IOException e){
				e.printStackTrace();
			}
			return str;
		}
	}

	public static boolean isPrime(int n) {
		if(n<2) return false;
		for(int i=2;i<=(int)Math.sqrt(n);i++) {
			if(n%i==0) return false;
		}
		return true;
	}

	public static void print(int a[],int l,int r){
		int i;
		for(i=l;i<=r;i++)
			out.print(a[i]+" ");
		out.println();
	}

	public static long fastexpo(long x, long y, long p){
		long res=1;
		while(y > 0){
			if((y & 1)==1)
				res= ((res%p)*(x%p))%p;
			y= y >> 1;
			x = ((x%p)*(x%p))%p;
		}
		return res;
	}

	public static boolean[] sieve (int n) {
		boolean primes[]=new boolean[n+1];
		Arrays.fill(primes,true);
		primes[0]=primes[1]=false;
		for(int i=2;i*i<=n;i++){
			if(primes[i]){
				for(int j=i*i;j<=n;j+=i)
					primes[j]=false;
			}
		}
		return primes;
	}

	public static long gcd(long a,long b){
        return (BigInteger.valueOf(a).gcd(BigInteger.valueOf(b))).longValue();
    }

    public static void merge(int a[],int l,int m,int r){
        int n1,n2,i,j,k;
        n1=m-l+1;
        n2=r-m;

        int L[]=new int[n1];
        int R[]=new int[n2];

        for(i=0;i<n1;i++)
            L[i]=a[l+i];
        for(j=0;j<n2;j++)
            R[j]=a[m+1+j];

        i=0;j=0;

        k=l;
        while(i<n1&&j<n2){
            if(L[i]<=R[j]){
                a[k]=L[i];
                i++;
            }
            else{
                a[k]=R[j];
                j++;
            }
            k++;
        }

        while(i<n1){
            a[k]=L[i];
            i++;
            k++;
        }
        while(j<n2){
            a[k]=R[j];
            j++;
            k++;
        }
    }
    public static void sort(int a[],int l,int r){
        int m;
        if(l<r){
            m=(l+r)/2;
            sort(a,l,m);
            sort(a,m+1,r);
            merge(a,l,m,r);
        }
    }
}


import java.util.*;
import java.io.*;
import java.math.*;
public class C621{

	public static void main(String args[]){
        FastReader sc = new FastReader();
        int i,j,n,count;
        char s[]=sc.next().toCharArray();
        int f[]=new int[26];
        n=s.length;
        for(i=0;i<n;i++)
            f[s[i]-'a']++;
        int pro=1;
        for(i=0;i<n;){
            count=0;
            for(j=i;j<n;j++){
                if(s[i]==s[j])
                    count++;
                else
                    break;
            }
            pro=pro*count;
            i=j;
        }
        int max=0;
        for(i=0;i<26;i++)
            max=Math.max(f[i],max);
        int ans=Math.max(max,pro);
        out.println(ans);
		out.flush();
	}

	static PrintWriter out;
	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br=new BufferedReader(new InputStreamReader(System.in));
			out=new PrintWriter(System.out);
		}
		String next(){
			while(st==null || !st.hasMoreElements()){
				try{
					st= new StringTokenizer(br.readLine());
				}
				catch (IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt(){
			return Integer.parseInt(next());
		}
		long nextLong(){
			return Long.parseLong(next());
		}
		double nextDouble(){
			return Double.parseDouble(next());
		}
		String nextLine(){
			String str = "";
			try{
				str=br.readLine();
			}
			catch(IOException e){
				e.printStackTrace();
			}
			return str;
		}
	}

	public static boolean isPrime(int n) {
		if(n<2) return false;
		for(int i=2;i<=(int)Math.sqrt(n);i++) {
			if(n%i==0) return false;
		}
		return true;
	}

	public static void print(int a[],int l,int r){
		int i;
		for(i=l;i<=r;i++)
			out.print(a[i]+" ");
		out.println();
	}

	public static long fastexpo(long x, long y, long p){
		long res=1;
		while(y > 0){
			if((y & 1)==1)
				res= ((res%p)*(x%p))%p;
			y= y >> 1;
			x = ((x%p)*(x%p))%p;
		}
		return res;
	}

	public static boolean[] sieve (int n) {
		boolean primes[]=new boolean[n+1];
		Arrays.fill(primes,true);
		primes[0]=primes[1]=false;
		for(int i=2;i*i<=n;i++){
			if(primes[i]){
				for(int j=i*i;j<=n;j+=i)
					primes[j]=false;
			}
		}
		return primes;
	}

	public static long gcd(long a,long b){
        return (BigInteger.valueOf(a).gcd(BigInteger.valueOf(b))).longValue();
    }

    public static void merge(int a[],int l,int m,int r){
        int n1,n2,i,j,k;
        n1=m-l+1;
        n2=r-m;

        int L[]=new int[n1];
        int R[]=new int[n2];

        for(i=0;i<n1;i++)
            L[i]=a[l+i];
        for(j=0;j<n2;j++)
            R[j]=a[m+1+j];

        i=0;j=0;

        k=l;
        while(i<n1&&j<n2){
            if(L[i]<=R[j]){
                a[k]=L[i];
                i++;
            }
            else{
                a[k]=R[j];
                j++;
            }
            k++;
        }

        while(i<n1){
            a[k]=L[i];
            i++;
            k++;
        }
        while(j<n2){
            a[k]=R[j];
            j++;
            k++;
        }
    }
    public static void sort(int a[],int l,int r){
        int m;
        if(l<r){
            m=(l+r)/2;
            sort(a,l,m);
            sort(a,m+1,r);
            merge(a,l,m,r);
        }
    }
}


import javax.print.DocFlavor;
import java.lang.reflect.Array;
import java.nio.charset.IllegalCharsetNameException;
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException {
        //Code starts
        FastReader ip = new FastReader();
        OutputStream output = System.out;
        PrintWriter out = new PrintWriter(output);
        String s=ip.nextLine();
        HashMap<Character ,Long> hm=new HashMap<>();
        for(int i=0;i<s.length();i++){
            if(hm.containsKey(s.charAt(i))){
                hm.put(s.charAt(i),hm.get(s.charAt(i))+1);
            }else{
                hm.put(s.charAt(i),(long)1);
            }
        }
        long max= Collections.max(hm.values());
        HashMap<Character,Long> map = new HashMap<>();
        HashMap<String , Long> hashMap = new HashMap<>();

        for(int i= s.length()-1;i>=0;i--){
            if(map.size()==0){
                map.put(s.charAt(i),(long)1);
            }else{
                for(Character x:map.keySet()){
                    String str=s.charAt(i)+""+x;
                    if(hashMap.containsKey(str)){
                        long v1=hashMap.get(str);
                        long v=map.get(x);
                        hashMap.put(str,v1+v);
                    }else {
                        long v=map.get(x);
                        hashMap.put(str,  v);
                    }
                }
                map.put(s.charAt(i),map.getOrDefault(s.charAt(i),(long)0)+1);
            }
//           out.println(hashMap);
        }
        if(!hashMap.isEmpty()) {
            out.print(Math.max(max, Collections.max(hashMap.values())));
        }else{
            out.print(1);
        }
        out.close();
        //Code ends
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
        FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); }
        String next() { while (st == null || !st.hasMoreElements()) {
            try { st = new StringTokenizer(br.readLine()); }
            catch (IOException e) { e.printStackTrace(); } }
            return st.nextToken();
        }

        int nextInt() { return Integer.parseInt(next()); }
        long nextLong() { return Long.parseLong(next()); }
        double nextDouble() { return Double.parseDouble(next()); }

        String nextLine() {
            String str = "";
            try { str = br.readLine(); }
            catch (IOException e) { e.printStackTrace(); }
            return str;
        }
    }

}


import javax.print.DocFlavor;
import java.lang.reflect.Array;
import java.nio.charset.IllegalCharsetNameException;
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException {
        //Code starts
        FastReader ip = new FastReader();
        OutputStream output = System.out;
        PrintWriter out = new PrintWriter(output);
        String s=ip.nextLine();
        HashMap<Character ,Integer> hm=new HashMap<>();
        for(int i=0;i<s.length();i++){
            if(hm.containsKey(s.charAt(i))){
                hm.put(s.charAt(i),hm.get(s.charAt(i))+1);
            }else{
                hm.put(s.charAt(i),1);
            }
        }
        int max= Collections.max(hm.values());
        HashMap<Character,Integer> map = new HashMap<>();
        HashMap<String , Integer> hashMap = new HashMap<>();

        for(int i= s.length()-1;i>=0;i--){
            if(map.size()==0){
                map.put(s.charAt(i),1);
            }else{
                for(Character x:map.keySet()){
                    String str=s.charAt(i)+""+x;
                    if(hashMap.containsKey(str)){
                        int v1=hashMap.get(str);
                        int v=map.get(x);
                        hashMap.put(str,v1+v);
                    }else {
                        int v=map.get(x);
                        hashMap.put(str,  v);
                    }
                }
                map.put(s.charAt(i),map.getOrDefault(s.charAt(i),0)+1);
            }
//           out.println(hashMap);
        }
        out.print(Math.max(max,Collections.max(hashMap.values())));
        out.close();
        //Code ends
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
        FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); }
        String next() { while (st == null || !st.hasMoreElements()) {
            try { st = new StringTokenizer(br.readLine()); }
            catch (IOException e) { e.printStackTrace(); } }
            return st.nextToken();
        }

        int nextInt() { return Integer.parseInt(next()); }
        long nextLong() { return Long.parseLong(next()); }
        double nextDouble() { return Double.parseDouble(next()); }

        String nextLine() {
            String str = "";
            try { str = br.readLine(); }
            catch (IOException e) { e.printStackTrace(); }
            return str;
        }
    }

}


import javax.print.DocFlavor;
import java.lang.reflect.Array;
import java.nio.charset.IllegalCharsetNameException;
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException {
        //Code starts
        FastReader ip = new FastReader();
        OutputStream output = System.out;
        PrintWriter out = new PrintWriter(output);
        String s=ip.nextLine();
        HashMap<Character ,Integer> hm=new HashMap<>();
        for(int i=0;i<s.length();i++){
            if(hm.containsKey(s.charAt(i))){
                hm.put(s.charAt(i),hm.get(s.charAt(i))+1);
            }else{
                hm.put(s.charAt(i),1);
            }
        }
        int max= Collections.max(hm.values());
        HashMap<Character,Integer> map = new HashMap<>();
        HashMap<String , Integer> hashMap = new HashMap<>();

        for(int i= s.length()-1;i>=0;i--){
            if(map.size()==0){
                map.put(s.charAt(i),1);
            }else{
                for(Character x:map.keySet()){
                    String str=s.charAt(i)+""+x;
                    if(hashMap.containsKey(str)){
                        int v1=hashMap.get(str);
                        int v=map.get(x);
                        hashMap.put(str,v1+v);
                    }else {
                        hashMap.put(str,  1);
                    }
                }
                map.put(s.charAt(i),map.getOrDefault(s.charAt(i),0)+1);
            }
//            out.println(hashMap);
        }
        out.print(Math.max(max,Collections.max(hashMap.values())));
        out.close();
        //Code ends
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
        FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); }
        String next() { while (st == null || !st.hasMoreElements()) {
            try { st = new StringTokenizer(br.readLine()); }
            catch (IOException e) { e.printStackTrace(); } }
            return st.nextToken();
        }

        int nextInt() { return Integer.parseInt(next()); }
        long nextLong() { return Long.parseLong(next()); }
        double nextDouble() { return Double.parseDouble(next()); }

        String nextLine() {
            String str = "";
            try { str = br.readLine(); }
            catch (IOException e) { e.printStackTrace(); }
            return str;
        }
    }

}


import javax.print.DocFlavor;
import java.lang.reflect.Array;
import java.nio.charset.IllegalCharsetNameException;
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException {
        //Code starts
        FastReader ip = new FastReader();
        OutputStream output = System.out;
        PrintWriter out = new PrintWriter(output);
        String s=ip.nextLine();
        HashMap<Character ,Long> hm=new HashMap<>();
        for(int i=0;i<s.length();i++){
            if(hm.containsKey(s.charAt(i))){
                hm.put(s.charAt(i),hm.get(s.charAt(i))+1);
            }else{
                hm.put(s.charAt(i),(long)1);
            }
        }
        long max= Collections.max(hm.values());
        HashMap<Character,Long> map = new HashMap<>();
        HashMap<String , Long> hashMap = new HashMap<>();

        for(int i= s.length()-1;i>=0;i--){
            if(map.size()==0){
                map.put(s.charAt(i),(long)1);
            }else{
                for(Character x:map.keySet()){
                    String str=s.charAt(i)+""+x;
                    if(hashMap.containsKey(str)){
                        long v1=hashMap.get(str);
                        long v=map.get(x);
                        hashMap.put(str,v1+v);
                    }else {
                        long v=map.get(x);
                        hashMap.put(str,  v);
                    }
                }
                map.put(s.charAt(i),map.getOrDefault(s.charAt(i),(long)0)+1);
            }
//           out.println(hashMap);
        }
        out.print(Math.max(max,Collections.max(hashMap.values())));
        out.close();
        //Code ends
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
        FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); }
        String next() { while (st == null || !st.hasMoreElements()) {
            try { st = new StringTokenizer(br.readLine()); }
            catch (IOException e) { e.printStackTrace(); } }
            return st.nextToken();
        }

        int nextInt() { return Integer.parseInt(next()); }
        long nextLong() { return Long.parseLong(next()); }
        double nextDouble() { return Double.parseDouble(next()); }

        String nextLine() {
            String str = "";
            try { str = br.readLine(); }
            catch (IOException e) { e.printStackTrace(); }
            return str;
        }
    }

}


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

public class C implements Runnable
{
    @Override
    public void run() {
        InputReader in = new InputReader(System.in);
        PrintWriter w = new PrintWriter(System.out);
        String q = in.nextLine(); // Scanner has functions to read ints, longs, strings, chars, etc.

        getRes(w, q);

        w.flush();
        w.close();
    }

    private static void getRes(PrintWriter w, String s) {
        //find two stacks of characters that have max multiplication
        //26*26*n
        int l = s.length();
        int[][] count = new int[l + 1][26];
        for (int i = 1; i <= l; i++) {
            int c = s.charAt(i - 1) - 'a';
            for (int k = 0; k < 26; k++) {
                count[i][k] = k == c ? count[i - 1][k] + 1 : count[i - 1][k];
            }
        }

        long res = 0;

        for (int k = 0; k < 26; k++) {
            res = Math.max(res, count[l][k]);
        }

        for (int i = 1; i <= l; i++) {
            long left = 0;
            long right = 0;
            for (int k = 0; k < 26; k++) {
                left = Math.max(left, count[i][k]);
                right = Math.max(right,count[l][k] - count[i][k]);
            }
            res = Math.max(res, (left * right);
        }
        w.println(res);
    }

    static class InputReader
    {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
        private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        public InputReader(InputStream stream)
        {
            this.stream = stream;
        }

        public int read()
        {
            if (numChars==-1)
                throw new InputMismatchException();

            if (curChar >= numChars)
            {
                curChar = 0;
                try
                {
                    numChars = stream.read(buf);
                }
                catch (IOException e)
                {
                    throw new InputMismatchException();
                }

                if(numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
        public int nextInt()
        {
            int c = read();

            while(isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-')
            {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do
            {
                if(c<'0'||c>'9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public long nextLong()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            long res = 0;

            do
            {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public double nextDouble()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.')
            {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.')
            {
                c = read();
                double m = 1;
                while (!isSpaceChar(c))
                {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public String readString()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do
            {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c)
        {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next()
        {
            return readString();
        }

        public interface SpaceCharFilter
        {
            public boolean isSpaceChar(int ch);
        }
    }

    public static void main(String args[]) throws Exception
    {
        new Thread(null, new C(),"Main",1<<27).start();
    }

}