#include <iostream>
#include <vector>
using namespace std;

static int ans = 0;

void small(vector<vector<int> >& paper, int x, int y){
  x+=2; y+=2;
  paper[x][y]++;
  if(paper[x][y]>ans) ans = paper[x][y];
  paper[x-1][y]++;
  if(paper[x-1][y]>ans && x-1>=2) ans = paper[x-1][y];
  paper[x+1][y]++;
  if(paper[x+1][y]>ans && x+1<=11) ans = paper[x+1][y];
  paper[x][y-1]++;
  if(paper[x][y-1]>ans &&  y-1>=2) ans = paper[x][y-1];
  paper[x][y+1]++;
  if(paper[x][y+1]>ans && y+1<=11) ans = paper[x][y+1];
}

void medium(vector<vector<int> >& paper, int x, int y){
  small(paper, x, y);
  x+=2; y+=2;
  paper[x-1][y-1]++;
  if(paper[x-1][y-1]>ans && x-1>=2 && y-1>=2) ans = paper[x-1][y-1];
  paper[x-1][y+1]++;
  if(paper[x-1][y+1]>ans && x-1>=2 && y+1<=11) ans = paper[x-1][y+1];
  paper[x+1][y-1]++;
  if(paper[x+1][y-1]>ans && x+1<=11 && y-1>=2) ans = paper[x+1][y-1];
  paper[x+1][y+1]++;
  if(paper[x+1][y+1]>ans && x+1<=11 && y+1<=11) ans = paper[x+1][y+1];

}

void large(vector<vector<int> >& paper, int x, int y){
  medium(paper, x, y);
  x+=2; y+=2;
  paper[x][y-2]++;
  if(paper[x][y-2]>ans && y-2>=2) ans = paper[x][y-2];
  paper[x][y+2]++;
  if(paper[x][y+2]>ans && y+2<=11) ans = paper[x][y+2];
  paper[x-2][y]++;
  if(paper[x-2][y]>ans && x-2>=2) ans = paper[x-2][y];
  paper[x+2][y]++;
  if(paper[x+2][y]>ans && x+2<=11) ans = paper[x+2][y];
}

int main(){
  vector<vector<int> >paper(14,vector<int>(14));
  int x,y,size;
  string str;
  while(true){
    getline(cin,str);
    x = str[0]-'0';
    y = str[2]-'0';
    size = str[4]-'0';// cout << "OK\n";
    if(size == 1)
      small(paper,x,y);
    else if(size == 2)
      medium(paper,x,y);
    else
      large(paper,x,y);
    //    cout << "NOK\n";
  }
  cout << ans << endl;
  return 0;
}