import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.HashSet; import java.util.Set; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); char[] s = br.readLine().toCharArray(); br.close(); int[] dx = {1, 0, 0}; int[] dy = {0, 1, -1}; int x = 0; int y = 0; Set set = new HashSet<>(); set.add(toStr(x, y)); for (int i = 0; i < s.length; i++) { int tx = dx[s[i] - 'a']; int ty = dy[s[i] - 'a']; if ((tx == 1 && ty == 0) || (tx == -1 && ty == 0)) { for (int j = 0; j < 3; j++) { if (dx[j] == tx && dy[j] == ty) { dx[j] = -dx[j]; } } } else if (tx == 0 && ty == 1) { int[] nx = Arrays.copyOf(dx, 3); int[] ny = Arrays.copyOf(dy, 3); int bx = 0; for (int j = 0; j < 3; j++) { if (dx[j] == tx && dy[j] == ty) { ny[j] = -1; } else if (dy[j] == 0) { bx = dx[j]; nx[j] = 0; ny[j] = 1; } } for (int j = 0; j < 3; j++) { if (dy[j] == -1) { nx[j] = -bx; ny[j] = 0; } } dx = nx; dy = ny; } else if (tx == 0 && ty == -1) { int[] nx = Arrays.copyOf(dx, 3); int[] ny = Arrays.copyOf(dy, 3); int bx = 0; for (int j = 0; j < 3; j++) { if (dx[j] == tx && dy[j] == ty) { ny[j] = 1; } else if (dy[j] == 0) { bx = dx[j]; nx[j] = 0; ny[j] = -1; } } for (int j = 0; j < 3; j++) { if (dy[j] == 1) { nx[j] = -bx; ny[j] = 0; } } dx = nx; dy = ny; } x += tx; y += ty; set.add(toStr(x, y)); } System.out.println(set.size()); } static String toStr(int x, int y) { return x + "," + y; } }