#include <stdio.h>
#import <Foundation/Foundation.h>
 
int main() {
 
  int N;
  scanf("%d", &N);
  
  NSInteger i;
  NSMutableArray *strings = [[NSMutableArray alloc] init];
  NSMutableDictionary *table = [[NSMutableDictionary alloc] init];
  table[@(1)] = @(1);
  NSInteger result = 0;
  for(i=0;i<1;i++) {
    char *str;
    scanf("%s", str);
    NSInteger j;
    NSInteger sum=0;
    for(j=0;j<10;j++) {
      sum += str[j] - '0';
    }
    NSNumber *sumNumber = [NSNumber numberWithInt: sum];
    if (table[sumNumber] != nil) {
      NSNumber *count = [NSNumber numberWithInt: [table[sumNumber] integerValue] + 1];
      table[sumNumber] = count;
    } else {
      table[sumNumber] = [NSNumber numberWithInt:1];
    }
  }
 
  for(NSNumber *count in [table allValues]) {
    result += count.integerValue;
  }
  printf("%d", result);
  return 0;
}