#include <bits/stdc++.h>
using namespace std;
int main() {
  int dum[] = {0,   70,  140, 210, 280,  350,  601,  671,
               741, 811, 881, 951, 1202, 1272, 1342, 1412};
  int x, y;
  char c;
  scanf("%d%c%d", &x, &c, &y);
  int num = x * 60 + y;
  int temp, i;
  if (num > 1412) {
    temp = 1440 - num;
  } else {
    for (i = 0; dum[i] <= 1412; i++) {
      temp = dum[i] - num;
      if (temp >= 0) break;
    }
  }
  cout << temp << endl;
}
