public class Test {
public static void main(String[] args) {
int cnt = 0;
for (int i = 1; i <= 12; i++) {
if (i == 10) {
cnt += 1;
continue;
}
for (int j = 0; j < 60; j++) {
int val = i * 100 + j;
if (i == 12) {
val = 200 + j;
} else if (i == 11) {
val = 110 + (j / 10);
}
if (val % 111 == 0) {
cnt++;
}
}
}
System.out.println(cnt * 2);
}
}