#include <bits/stdc++.h>
using namespace std;
int rev(int mini) { return (mini % 10) * 10 + (mini / 10); }
int main() {
  int ans = 0;
  int hour, mini;
  string str;
  cin >> str;
  hour = (str[0] - '0') * 10 + (str[1] - '0');
  mini = (str[3] - '0') * 10 + (str[4] - '0');
  while (hour != rev(mini)) {
    ans++;
    mini++;
    if (mini == 60) {
      mini = 0;
      hour++;
      if (hour == 24) {
        hour = 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
