#include<stdio.h>
#include<string.h>
#include <stdlib.h>
#include <unistd.h>
#define MASK "255.255.0.0"
int dealMask(int x,int *buf,int ret){
int i = ret * 8;
while( (x/2) !=0 )
{
buf[i-1] = x%2;
x = x/2;
i--;
}
buf[i-1] = x%2;
return i;
}
int transer(char *mark){
char temp[8] = {0};
int buf[32] = {0};
char *str = temp;
char *head = mark;
int count = 0;
int ret = 1;
int i = 0;
int j = 0;
while(*head != '\0'){
*str = *head;
if(*(head+1) == '.'|| *(head+1)== '\0'){
head = head +2;
dealMask(atoi(temp),buf,ret);
ret++;
memset(temp,0,sizeof(temp));
str = temp;
continue;
}
str++;
head++;
}
for(i = 1;i <33;i++){
if(buf[i-1] == 1){
j++;
}
printf("%d",buf[i-1]);
if((i%8) == 0){
printf("\n");
}
}
printf("%d",j);
}
int main(){
transer(MASK);
return 0;
}