#include <stdio.h>

void part1() {
  printf("Part 1\n");

  int result = 0;
  char first = 0, prev, ch;
  ch = getchar();

  while(ch) {
    if(first == 0) { first = ch; }
    prev = ch;
    ch = getchar();
    if(ch == '\n') {
      break;
    }
    if(ch == prev) {
      result += prev - '0';
    }
  }

  if(prev == first) {
    result += prev - '0';
  }

  printf("%d\n", result);
}

void part2() {
  printf("Part 2\n");

  int result = 0;
  char first = 0, prev, ch;
  ch = getchar();
  char* input;
  gets

  while(ch) {
    if(first == 0) { first = ch; }
    prev = ch;
    ch = getchar();
    if(ch == '\n') {
      break;
    }
    if(ch == prev) {
      result += prev - '0';
    }
  }

  if(prev == first) {
    result += prev - '0';
  }

  printf("%d\n", result);
}

int main(int argc, char **argv) {
  printf("Args: %d\n", argc);
  int doPart = 1;
  if(argc > 1) { doPart = argv[1][0] - '0'; }
  if(doPart == 1) {
    part1();
  } else {
    part2();
  }
  return 0;
}

