#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, m;
  scanf("%d:%d", &h, &m);
  int tmp = 0;
  int htmp = h;
  tmp = h % 10;
  tmp = tmp * 10;
  tmp = tmp + h / 10;
  if (tmp >= m && tmp < 60)
    printf("%d\n", tmp - m);
  else {
    h++;
    while (true) {
      tmp = 0;
      tmp = h % 10;
      tmp = tmp * 10;
      tmp = tmp + h / 10;
      if (tmp < 60) break;
      h++;
    }
    tmp = (h - htmp - 1) * 60 + tmp + (60 - m);
    if (h == 24) {
      tmp = 0;
      printf("%d\n", 60 - m);
    } else
      printf("%d\n", tmp);
  }
  return 0;
}
